Error: 'for' loop initial declaration used outside c99 mode

Submitted by rex on Tue, 05/05/2009 - 00:53

What is wrong with this in c?


for(int i=0;i ....
}

this for loop is allow in c++ or in java, but if you compile your c code with gcc you will get the error:

'for' loop initial declaration used outside c99 mode

to resolve this problem just declare your variable before of you 'for loop' like


int i;
for(i=0;i ...
}

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.