C: problema con char *
/*
* code.c
*
* TASK
* Reverse a string by reversing pointers. Function should use return
* type char* and use a char* parameter as input.
*/
#include <stdio.h>
#include <string.h>
#define STRMAX 51
char* reverse(char* sPhrase[]);
int main() {
char sPhrase[STRMAX];
char sReverse[STRMAX];
printf("Enter string (max. 50 chars): ");
gets(sPhrase);
sReverse = reverse(sPhrase);
return 0;
}
char* reverse(char* sPhrase[]) {
char* sOutput[STRMAX];
int iCnt = 0, iCntRev;
for (iCntRev = strlen(*sPhrase)-2; iCntRev >= 0; iCntRev--) {
sOutput[iCnt] = sPhrase[iCntRev];
iCnt++;
}
*sOutput[iCnt] = '\0'; // Don't forget to close the string
return sOutput;
}
Este código tiene algunas peculiaridades:
sReverse = reverse(sPhrase);
return sOutput;
¿Qué significan estas advertencias? ¿Cómo puedo parchear los errores? La función debe mantener char * como tipo de retorno y como parámetro ya que estoy haciendo este pequeño programa como parte de un curso de capacitación en C.