The unary increment operator in pointer arithmetic
Posted
by
RhymesWithDuck
on Stack Overflow
See other posts from Stack Overflow
or by RhymesWithDuck
Published on 2010-12-26T04:30:46Z
Indexed on
2010/12/26
4:54 UTC
Read the original article
Hit count: 186
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
© Stack Overflow or respective owner