I have this code:
#include <stdio.h>
void f(int* n){
*n++;
}
int main() {
int n= 1;
f(&n);
printf("%d\n", n);
return 0;
}
The value of n doesn't change.
If I want to change the value of n I must do this:
#include <stdio.h>
void f(int* n){
(*n)++;
}
int main() {
int n= 1;
f(&n);
printf("%d\n", n);
return 0;
}
Why are the parentheses so important, and what's the difference between these two lines of code?
*n++;
(*n)++;