old_fun() { int a = 10; int *ptr = &a; new_fun(&a); // passing address case 1 new_fun(ptr); // passing address case 2 } new_fun(int *ptr) { *ptr = 50; }
Here, case 1 will affect of "a" of old_fun but case 2 wont affect why ?
Looks that you have missed something I tested the following code
new_fun(int *ptr) { *ptr = 50; } main() { int a = 10; int *ptr = &a; new_fun(&a); printf("%d\n", a); new_fun(ptr); printf("%d\n", a); }
Output
50 50
I actually changed the new_func to this one in Salil's code
new_fun(int *ptr) { (*ptr)++; }
and output was 11 12 so this question does not seems to be valid.
11 12
What is the point of declaring Pointer of different types (eg. integer,float,char) as we all know pointer takes 4 bytes of space regardless which type of pointer it is and only contains address?