#include <stdio.h>
int main()
{
char a[] = "hello";
char *ptr = a;
printf ("%c\n",*ptr++);//it prints character 'h'.
printf ("%c\n",*ptr);//it prints character 'e'.
return 0;
}
As I understand it: In the above code, in *ptr++
expression, both *
and ++
have same precedence and operation will take place from right to left, which means pointer will increment first and deference will happen next. So it should print the character 'e'
in the first printf
statement. But it is not.
So my question is: Where will it store the incremented value (in, *ptr++
) if it is not dereferencing that location in first printf
statement?