Yes, I know I shouldn't be using scanf. I'd still like to know why this doesn't work though.
With scanf reading into the float variable first, it shows up as 0.0000... but the double variable shows up fine.
With scanf reading the double variable first, both numbers print out exactly as they should. Why is this?
Code:
#include <stdio.h>
union floatingPoint {
float f;
double d;
long double x;
} test[ 3 ];
int main()
{
int i;
scanf( "%f%lf", &(test[ 0 ].f), &(test[ 0 ].d) );
printf( "%f %lf\n", test[ 0 ].f, test[ 0 ].d );
return 0;
}
Code:
eugene@eugene-laptop:~/cfiles$ ./a.out
1 1
0.000000 1.000000