Skip to content
Home » error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Let’s start the discussion about error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode in following Approaches.

This is because declaring variables inside a for loop was not valid C until C99 (the C standard published in 1999). You can either declare your counter outside the for as others have suggested, or use the -std=c99 flag to explicitly tell the compiler that you’re using this standard and that it should interpret it as such.

error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode ?

/*
This happens because declaring variables inside a for loop 
wasn't valid C until C99(which is the standard of C published in 1999), 
you can either declare your counter outside the for
or use the -std=c99 flag to tell the compiler explicitly 
that you're using this standard and it should interpret it as such.
*/
int j;
for(j=0;j<5;j++)
printf("%d",Arr[j]);

I hope the strategies listed above work for you. Happy coding and come back again.

Similar Post : How to change the space between the itemize "items" in LaTeX