我有以下代码:
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 */
}
我假设该scanf()
命令失败,因为 *sPPhrase 不可写,因为 sPPhrase 指向字符串常量。编译器没有任何错误的线索。稍后,我需要将此字符串传递给此函数:
char* reverse(char* sPPhrase[]);
字符串常量不可写,但我需要将此 char* 传递给此函数。如何重写我的代码以使其工作?