While working on Exercises from the course “Learn C from Scratch” I came across this problem many times. Sometimes the code works fine on my computers Xcode but this error is visible on Educative. What is the issue?
Here is my code:
char * toUpperCase(char * province)
{
int i=0;
while (province[i]!= 0)
{
if ((province[i] >= 'a') && (province[i] <= 'z'))
{
province[i] = province[i] - 32;
}
i++;
}
return province;
}
Here is the error:
main.c: In function ‘toUpperCase’:
main.c:7:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int c = 0; c < strlen(province); c++){
^
main.c:7:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
Course: Learn C from Scratch - Free Interactive Course
Lesson: Exercises on Strings