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

Using gcc to compile code

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

note: use option -std=c99 or -std=gnu99 to compile your code

Error, because the increment is initialized directly in the for loop in GCC:

for(int i=0; i<len; i++)
{

}

This syntax is wrong in GCC. You must first define the I variable:

int i;
for(i=0;i<len;i++)
{
 
}

This is because GCC is based on the C89 standard. If you change to the C99 standard, you can define the I variable in the for loop and add it in the makefile

CFLAGS += -std=c99

Read More: