#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int x, *ptr_x;
float f , *ptr_f;
ptr_f = &f;
ptr_x = &x;
*ptr_x = 5;
*ptr_f = 1.5; //printf("%d %f
", f,x);
printf ("
xd = %d xf = %f
ff = %f fd = %d", x,x,f,f);
return 0;
}
The output for ff = %f is not expected.
xd = 5 xf = 0.000000
ff = 0.000000 fd = 1073217536
The point of the this code is to show what would happen if a floating value is printed with %d and if a int value is printed %f.
Why is the float value not being printed properly even if i use %f ?
See Question&Answers more detail:os