Simple: you don't call
f
at all in that code.
You call a function called
change
- but we don't have source code for that and it's very likely that your code doesn't compile. If it doesn't compile, no EXE file is produced, so any EXE you execute doesn;t reflect the latest changes to your source code.
Even if you did, you don't change what
p
points to: you set a new value for the local parameter variable
p
which isn't reflected in the "outside world" because in C all parameters are passed by value: a copy is made of the value you pass rather than any actual variable.
Try this:
#include <stdio.h>
void f(int *p, int a) {
*p = a;
}
int main() {
int i = 10, j = 20;
f(&i, j);
printf("%d", i);
return 0;
}
Now you pass the address of
i
to the function and alter the value of the variable it points to, so the result printed changes.