What is this address coming from?


My question is last two printf function in the code.

[code]#include <stdio.h>

int main(int argc, const char * argv[])

int a = 12;
int *a_ptr = &a;
int *test = NULL;

printf("%d\n", *a_ptr); // where pointer varialbe 'a_ptr' is pointing, variable a's value.
printf("%p\n", a_ptr); // address that pointer varialbe 'a_ptr' has.
printf("%p\n", &a_ptr); // address of the pointer variable 'a_ptr'.
printf("%p\n", &a); // address of varialbe a avlue is stored.
printf("%p\n", a); // WHAT IS THIS ADDRESS COMING FROM?
printf("%p\n", test); // IS "0x0 is always NULL's address which is 0?

return 0;



That statement is kaput because %p requires the address of an object.; it will print the value of a as address of something.
Xcode will warn you: “Conversion specifies ‘void *’ but the argument has type ‘int’”

It should be:

printf ("%p\n", &a);

No, it’s not NULL’s address; 0x0 is NULL’s value in hex notation. (NULL is b[/b].)


Thank you for the reply.
Very satisfied.