Incrementation of pointer within a function

Hello, the code below functions properly, the output is 23. And yet I’m confused why it doesn’t output the same result (the output stays 22) when I increment the Pointer by writing *agePointer++; instead of *agePointer += 1;

Doesn’t the code mean the exact same thing? Thx in advance :smiley:

void incrementAge(int *agePointer){
  *agePointer += 1;
}

int main(void) {
    int age = 22;
    incrementAge(&age);
    printf("%d\n", age);
}
1 Like

Good observation.

Have a look at these:

1 Like