Please suggest what is wrong with this string reversal fucntion(C++)?
- by AKS
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';
}