I'm trying to learn about C pointers but I cannot understand somethings... The following code:
#include <stdio.h>
void foo(int *x, int *y);
void foo(int *x, int *y) {
printf("x = %p\ny = %p\n", &x, &y);
*x = 5;
*y = 6;
}
int main(void) {
int a, b;
printf("a = %p\nb = %p\n", &a, &b);
foo(&a, &b);
return 0;
}
Why are the addresses different? The first printf (main) output two addresses. the other printf (foo) output diferent addresses. I'm passing addresses to foo (& operator).
Thank you