What it points to?
C Interview Questions and Answers
(Continued from previous question...)
What it points to?
Q: Does *p++ increment p, or what it points to?
The postfix ++ and -- operators essentially have higher precedence than the prefix unary operators. Therefore, *p++ is equivalent to *(p++); it increments p, and returns the value which p pointed to before p was incremented. To increment the value pointed to by p, use (*p)++ (or perhaps ++*p, if the evaluation order of the side effect doesn't matter).
(Continued on next question...)
Other Interview Questions
|