This is in reference to a solution posted on: http://stackoverflow.com/questions/1969588/looping-a-fixed-size-array-without-defining-its-size-in-c
Here's my sample code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
static const char *foo[] = {
"this is a test",
"hello world",
"goodbye world",
"123",
NULL
};
for (char *it = foo[0]; it != NULL; it++) {
printf ("str %s\n", it);
}
return 0;
}
Trying to compile this gives:
gcc -o vararray vararray.c
vararray.c: In function ‘main’:
vararray.c:14: warning: initialization discards qualifiers from pointer target type
vararray.c:14: error: ‘for’ loop initial declaration used outside C99 mode