it prints 51, why? what exactly is this number? it's the memory address of what?Code:#include <stdio.h> int main(void){ int *a,*b; int c=10; a = &c; printf("%d\n",&(*b)); getchar(); return 0; }
ty
it prints 51, why? what exactly is this number? it's the memory address of what?Code:#include <stdio.h> int main(void){ int *a,*b; int c=10; a = &c; printf("%d\n",&(*b)); getchar(); return 0; }
ty
It is printing the address that the variable b is located at. If you wanted to print what variable b actually was, your printf statement should appear as follows:
Also note that you have not even initialized b.Code:printf("%d\n",*b);
Also you are passing an (int *) to printf when it is expecting an int. You should be ok because I'm guessing that the machine you are using they are both the same size, but passing unexpected arguments can often result in undefined behavior.
Last edited by carrotcake1029; 02-12-2010 at 01:20 PM.
thanks a lot