Quantcast
Viewing latest article 2
Browse Latest Browse All 25

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 Image may be NSFW.
Clik here to view.
:smiley:

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

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

2 posts - 2 participants

Read full topic


Viewing latest article 2
Browse Latest Browse All 25

Trending Articles