This is a much discussed question however my doubt is that in C, *t++ is equivalent to *(t++) as precedence of ++ (post increment operator) is greater than *. Therefore,in while (*t++ = *s++); won't the first character be skipped while copying from s to t; To frame it better, will the copy take place before the increment operator or afterwards and why?
Asked
Active
Viewed 20 times
-2
-
You could write a test program and learn it for yourself... – John3136 Jul 20 '16 at 23:37
1 Answers
2
No, the first character won't be skipped. The result of evaluating t++
(post-increment) is the value of t
before the increment occurred, so the pointer dereference goes to the position pointed to before t
was incremented. You can use the pre-increment operator (++t
) to increment t
and produce the value after the increment.

Todd Knarr
- 1,255
- 1
- 8
- 14