Can't Understand this simple code output

c

Solution

- The first is obviously 5, just dereferencing a pointer

- Still five because the postfix operator returns the pointer preincrement

- 3 and 4 are junk because the pointer no longer points to memory that has been assigned

If you want the second to act like you expected and print junk you can use the prefix `++` instead

Problem

Code: ``` int a = 5; int *ptr; ptr = &a; printf("%d",*ptr); printf("\n%d",*(ptr++)); printf("\n%d",(*ptr)++); printf("\n%d",++(*ptr)); ``` Output: ``` 5 5 1638268 1638268 ``` and I am expecting the output to be: 5 junk 5 7 Sory, my pointer and operator precedence concept is very bleak. Can't understand this simple ouput.

Original source