'for' loop initial declaration used outside C99 mode

From Cppsyntax

Jump to: navigation, search

You can get the error

  'for' loop initial declaration used outside C99 mode

if you try to declare a variable inside a for loop without turning on C99 mode.

Back in the old days, when dinosaurs roamed the earth and programmers used punch cards, you were not allowed to declare variables anywhere except at the very beginning of a block.

ERROR IN NON-C99 MODE

 for (int i = 0; i<10; i++) 
 {
   printf("i is %d\n", i);
 }

CORRECT

 int i;
 for (i = 0; i<10; i++) 
 {
   printf("i is %d\n", i);
 }

ANOTHER WAY You can also compile with the C99 switch set. Put -std=c99 in the compilation line:

 gcc -std=c99 foo.c -o foo


More

Wikipedia entry for C99

pharmacie en ligne viagra professional cialis professional acheter viagra soft acheter viagra acheter propecia acheter cialis acheter tadalis acheter silagra acheter levitra acheter kamagra acheter caverta acheter kamagra oral jelly acheter cialis soft acheter kamagra soft
Personal tools