The unary increment operator in pointer arithmetic
- by RhymesWithDuck
Hello, this is my first post.
I have this function for reversing a string in C
that I found.
void reverse(char* c) {
if (*c != 0) {
reverse(c + 1);
}
printf("%c",*c);
}
It works fine but if I replace:
reverse(c + 1);
with:
reverse(++c);
the first character of the original string is truncated. My question is why would are the
statements not equivalent in this instance?
Thanks