[Linux & gcc]
I'm taking C courses and pluralsight.com and I'm both getting an error with a program I got from one of their videos as well as having some trouble understanding something in the code
#include <stdio.h>
#include <ctype.h>
int main()
{
char message[] = "Hello world!";
for(char *p = message; *p; ++p)
{
if(isupper(*p)) *p = (char)tolower(*p);
else if(islower(*p)) *p = (char)toupper(*p);
}
printf(message);
}
When I try to compile this program in gcc I get this error ->
stringpointer.c:8:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(char *p = message; *p; ++p)
^
stringpointer.c:8:5: note: use option -std=c99 or -std=gnu99 to compile your code
stringpointer.c:14:5: warning: format not a string literal and no format arguments [-Wformat-security]
printf(message);
^
Also I'm having trouble understanding the for loop because I don't see a condition that says, if we hit '\0' we are done.