Machine-translated by Google. Questions are authored in English.
Top

Discussion

Are the expression *ptr++ and ++*ptr are same?

  • A.True
  • B.False

Answer: B

Correct answer: False

They differ in what is incremented. *ptr++ parses as *(ptr++), because the postfix ++ binds more tightly than the unary *: it yields the value currently pointed to and advances the pointer.

++*ptr parses as ++(*ptr): it dereferences first and increments the pointed-to value, leaving the pointer where it was. The first walks along an array reading it; the second modifies one element in place.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.