void print_pointer_2(int* i) {
^
Here is the local variable, you're
printing the address of this local variable.
printf("In print_pointer_2 address is : \t\t\t%p\n", &i);
}
So you're just printing the address of a local variable. You would rather print the value of the pointer, as that pointer stores the address you assigned to it in main()
printf("In print_pointer_2 address is : \t\t\t%p\n", i);
This will naturally print the address of j
, not the address of your i
variable in main, as
your print_pointer_1() function does. print_pointer_2() has no way of knowing the address of main()'s i