using GCC to compile the code is to report
error: ‘for’ loop initial declarations are only allowed in C99 mode
note: use option -std=c99 or -std=gnu99 to compile your code
The
error is due to the increment being initialized in GCC directly in the for loop:
- for (int I = 0; I< len; I++) { li>
- } li> ol>
this syntax is incorrect in GCC, you must first define the I variable:
- int I; li>
- for (I = 0; i< len; I++) { li>
- li>
- } li> ol>
this is because GCC is based on the c89 standard, instead of the C99 standard, you can define the I variable within the for loop:
gcc src.c -std=c99 -o src