I'm working my way slowly through a book called 'Learn C on the Mac' and I am doing the exercises at the end of the chapter. They ask you to predict the result based on being able to follow the code and understand it. The answer is 25 but I don't get how they managed to get that result. Obviously I won't ever understand the basics if I don't take the problem as far as I can before getting help. So what I have done is paste first the code they gave me and then the code again but with my notes on what of it that I understand....

void AddOne( int *myVar );

int main (int argc, const char * argv[]) {
int num, i;

num = 5;

for ( i = 0; i < 20; i++ )
AddOne( &num );

printf( "Final value is %d.", num );

return 0;
}

void AddOne( int *myVar ) {
(*myVar) ++;
}


And now my interpretation of the code...

void AddOne( int *myVar ); <-- Here is where the AddOne function is declared with a variable that is actually a pointer to myVar.

int main (int argc, const char * argv[]) { Main will be an integer.
int num, i; declaration of the variable 'mum' which is an integer

num = 5; initialization of the variable 'num' to a value of '5'

for ( i = 0; i < 20; i++ ) a for loop that starts at 0 and will continue to go through the loops until it reaches 19.
AddOne( &num ); The function AddOne is called so we go to the code of the function next...

printf( "Final value is %d.", num );

return 0;
}

void AddOne( int *myVar ) { And now I am lost!!
(*myVar) ++;
}


If anyone could please please walk me through the last part I would greatly appreciate it. I figure the sticking point has something to do with being a little unclear on pointers so I'm interest to see what you think.

Thanks