Christian Christian - 1 year ago 95
C Question

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?

Answer Source

I assume you are missing an include. Try:

#include <string.h>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download