Quantcast
Channel: C - Codecademy Forums
Viewing all articles
Browse latest Browse all 25

Incrementation of pointer within a function

$
0
0

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);
}

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 25

Trending Articles