据我所知,输出应该像 3.14,3.14,3.14 和 256,256,256 对吗?但这会产生不同的输出。谁能指导我完成这个并告诉我为什么会发生这种情况?
main()
{
float a = 3.14;
int b = 256;
char *p, *p1;
p = (char *) &a;
p1 = (char *) &b;
printf("\nFLOAT:");
printf("\nValue of *p=%f",*p);
printf("\nValue of a=%f",a);
printf("\nValue of *p=%f",*p);
printf("\n\nINTEGER:");
printf("\nValue of *p1=%d",*p1);
printf("\nValue of b=%d",b);
printf("\nValue of *p1=%d",*p1);
}
Output:
FLOAT:
Value of *p=0.000000
Value of a=3.140000
Value of *p=3.140001
INTEGER:
Value of *p1=0
Value of b=256
Value of *p1=0