I have had the recent pleasure to explain pointers to a C programming beginner and stumbled upon the following difficulty. It might not seem like an issue at all if you alre
I'd rather read it as the first *
apply to int
more than bar
.
int foo = 1; // foo is an integer (int) with the value 1
int* bar = &foo; // bar is a pointer on an integer (int*). it points on foo.
// bar value is foo address
// *bar value is foo value = 1
printf("%p\n", &foo); // print the address of foo
printf("%p\n", bar); // print the address of foo
printf("%i\n", foo); // print foo value
printf("%i\n", *bar); // print foo value