char *_strreverse(const char *str1){
if (str1 == NULL){
return NULL;
}
char str[strlen(str1)];
strcpy(str,str1);
for (int i = 0; i < strlen(str) - 1; ++i){
int t = str[strlen(str) - 1];
memmove(str + strlen(str) - 1,str + strlen(str), 2);
memmove(str + i,str - 1 + i, strlen(str) - i + 1);
str[i] = t;
}
return str;
}
Here is the function(it should reverse string) I have warning: function returns address of local variable [-Wreturn-local-addr]
Signature should be same, static char isn't allow, malloc can't be used. What should i do?