I'm having a hard time understanding this short snippet of code. When you pass a pointer to a function and then use the postfix increment operator, why does the value of the pointer keep its original value after it exits the function?
Code:
int main(void)
{
char line[LIMIT];
puts("Please enter a line:");
gets(line);
ToUpper(line);
printf("%p \n", line);
puts(line);
printf("%p \n", line);
return 0;
}
void ToUpper(char * str)
{
while (*str)
{
*str = toupper(*str);
str++;
}
}
Output:
Please enter a line:
testing...
0x7fffffffea40
TESTING...
0x7fffffffea40