rewrite a function using only pointer increment/decrement

Posted by Richard Nguyen on Stack Overflow See other posts from Stack Overflow or by Richard Nguyen
Published on 2011-11-13T09:33:26Z Indexed on 2011/11/13 9:50 UTC
Read the original article Hit count: 221

Filed under:

can anyone help me rewrite the function i wrote below using only points and pointer increment/decrement? I dont have much experience with pointer so I dont know what to do.

void reverse(char * s)
{
    int i, l = strlen(s);
    char c;
    for(i = 0; i < (l >> 1); i++)
    {
       c = s[i];
       s[i] = s[l - i - 1];
       s[l - i - 1] = c;
    }
}

do not use pointer arithmetic or array notation. any help or hint on how to rewrite the function above is appriciated. Thanks!

© Stack Overflow or respective owner

Related posts about c++