Search code examples
cfor-loopcompiler-errorsc99strlen

Error: Declaration of non-variable 'strlen' in 'for' loop initial declaration - C


The title is the exact error my compiler(geany on ubuntu) gives me when I try to compile. The part of code in question is the following:

for(int q=strlen(stringA)-1;q>0;q--)
{
//do stuff
}

I've already set the C99 mode and the initialization of variables in the 'for' header is accepted. Is what I did simply illegal in C?


Solution

  • I assume you are missing an include. Try:

    #include <string.h>