call by referenz bei float zahlen anwenden

Gast #2549267
Lesenswert?
• ▲
▼
Hallo,
weshalb geht folgendes nicht:
1
#include <stdio.h>
2
#include <stdlib.h>
3

4
void main ()
5
{
6
     float x = 1.76, y = 1.88;
7
     funk( &x, &y );
8

9
         printf("%d\n",x);
10
         return 0;
11

12

13
}
14
void funk (float* a, float* b)
15
{
16

17
     *b = 2;
18
    *a =5.56 ;
19
}



Hätte die Ausgabe: 5.56 erwartet!erhalte aber
-1610612736

bei "Int" funktioniert das ganze
1
#include <stdio.h>
2
#include <stdlib.h>
3

4
void main ()
5
{
6
     int
7
    x = 0, y = 0;
8
     funk( &x, &y );
9

10
         printf("%d\n",x);
11
         return 0;
12

13

14
}
15
void funk (int* a, int* b)
16
{
17

18
     *b = 2;
19
    *a =5 ;
20
}





Hier erhalte ich als Ausgabe den Wert 5



Gruß Feldi

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren