pointers1

main()
{
char a,*b;
int i;
float f;

a='Z';
i=20;
f=3.14;

b=&a;
printf("a= %c b=%u\n",*b,b);
b=(char *)&i;
printf("i= %d b=%u\n",*b,b);
b=(char *)&f;
printf("f=%f b=%u\n",*b,b);

return 0;
}

output:
a=Z b=65525
i=20 b=65522
f=-1.000000000e+259 b=16270

first output i got but in second i think *b should give the value at first byte address of integer value as b is a character and b should be equal to 65523 and for third i dont know how???

please help me.....pointers are seeming like hard nut to crack.
The type of the expression *b is char. Sending it to printf which expects a float or double (due to %f) invokes undefined behavior. There is no meaning in the value you observed as output.
Topic archived. No new replies allowed.