I have the following code:
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 */
}
The scanf()
command fails, I assume, because *sPPhrase is not writable as sPPhrase points to a string constant. The compiler doesn't have a clue of anything being wrong. A little later on, I need to pass this string to this function:
char* reverse(char* sPPhrase[]);
The string constant is not writable, but I need to pass this char* on to this function. How do I rewrite my code to make it work?