I'm trying to write a function in C to return
the reverse of the a string that is passed into to the function.
Once the string is passed in I declare a local char []
to fill with the reverse of the string.
However, when I compile the program I receive a warning stating warning: function returns address of local variable return test;
Am I allowed to return local variable pointers from functions in C?
char *reverseString(char *str)
{
int i, j;
char test[strlen(str)];
if(str == 0)
return;
for(i = 0, j = strlen(str); i < strlen(str), j >= 0; i++, j--)
str[j] = test[i];
return test;
}