次のコードがあります。
int main() {
char *sPPhrase[51];
/* Input */
printf("Enter string (max. 50 chars):\n");
fflush(stdout); /* Works around an annoying Eclipse bug that fails to display the output from the printf command */
scanf("%s", *sPPhrase); /* Won't work */
/* More code goes here */
}
sPPhrasescanf()
は文字列定数を指しているため、*sPPhrase は書き込み可能ではないため、コマンドは失敗すると思います。コンパイラは、何かが間違っているという手がかりを持っていません。少し後で、この文字列をこの関数に渡す必要があります。
char* reverse(char* sPPhrase[]);
文字列定数は書き込み可能ではありませんが、この char* をこの関数に渡す必要があります。コードを書き直して機能させるにはどうすればよいですか?