char* reverse(char* mystring) //revere the string
{
int len = LenString(mystring);
int i, j;
// char *str = new char;
char *str = mystring;
i = 0;
j = len - 1;
str = mystring;
char temp;
char temp1;
while (i < j)
{
temp = str[i];
temp1 = str[j];
str[i] = temp1;
str[j] = temp;
i++;
j--;
}
return str;
}
I tried to dynamically allocate array as well but still getting same error. If I need to make some changes do let me know. I cannot change my function from char* reverse(char* mystring)
to any other type.
Aucun commentaire:
Enregistrer un commentaire