I cannot explain the output of the program. ++ has an higher precedence than *, but how can you explain the following output, especially the last two lines:
http://en.cppreference.com/w/c/language/operator_precedence
This link says that postfix ++ has an higher precedence than * operator. But on line 6 why isn't the postfix ++ operation is done firsts and then dereferenced by * operator? I thought it should print 44...
pointer initially points to 0x7fff51076248 (value there:22)
evaluate *p++
===============
step 1. evaluate postfix ++
before increment, pointer points to 0x7fff51076248 (value there:22)
after increment, pointer points to 0x7fff5107624c (value there:44)
postfix ++ returns a prvalue (value of pointer before the increment) 0x7fff51076248 (value there:22)
step 2. dereference pointer pointing to 0x7fff51076248 (value there:22)
return reference to int with value 22