Printing the value of a pointer in C -


int main() { int *i,*j;  printf("%u",i); } 

the above program result in output 0

int main() {  int *i,*j;  j=i; printf("%u",i); } 

but

the above program result in non zero. why?

both pointers not initialized initial value indeterminate. accessing uninitialized pointer undefined behavior.

moreover use p conversion specifier print pointer value (and yes cast required) u requires unsigned int argument :

printf("%p\n", (void *) i); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -