Please suggest what is wrong with this string reversal function?

Posted by AKS on Stack Overflow See other posts from Stack Overflow or by AKS
Published on 2010-03-26T23:17:13Z Indexed on 2010/03/26 23:33 UTC
Read the original article Hit count: 305

Filed under:
|

This code is compiling clean. But when I run this, it gives exception "Access violation writing location" at line 9.

void reverse(char *word)
{
int len = strlen(word);
len = len-1;
char * temp= word;
int i =0;
while (len >=0)
{
word[i] = temp[len-1];  //line9
++i;--len;
}
word[i] = '\0';
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about string-manipulation