B
blmblm
I merged your code into mine. It appears I muffed something in line 31.
gcc NL_pxm-array.c
_pxm-array.c: In function 'main':
_pxm-array.c:31:5: error: 'for' loop initial declarations are only
allowed in C99 mode
_pxm-array.c:31:5: note: use option -std=c99 or -std=gnu99 to compile
your code
So - follow the instructions. Add the option -std=c99 to your compiler
command line.
_pxm-array.c:32:13: warning: assignment makes pointer from integer
without a cast [enabled by default]
This implies that the compiler thinks that the call to strtok() returns
an integer, which is not the case. Why would it think that? Because
strtok() is declared in <string.h>, and your code doesn't include that
header. In C90, if you used an undeclared identifier as if it were the
name of a function, it get implicitly declared as a function returning
'int'. C99 has more reasonable behavior: it's a constraint violation to
attempt calling an undeclared function.
Ah, that explains ....
I was going to strongly recommend that the OP make a habit of
compiling with flags to enable optional warnings ("-Wall -pedantic"
is what I usually use, that being a reasonable compromise for
me between "all possible warnings" and "too much to type" [*]),
in which case gcc would have produced the warning message
qq.c:32: warning: implicit declaration of function 'strtok'
which is at least a clue about the real problem.
In the course of confirming that my advice wasn't going to be total
nonsense, I observed that just "-std=c99" produces the warning about
implicit declaration. Which now makes sense!
Be that as it may, I still vote for compiling with at least a minimal
set of "show me more warnings" flags -- not infrequently (as in this
case) the extra warnings are clues about behavior that otherwise could
be puzzling.
[*] Yes, yes, makefiles, scripts, aliases .... Sometimes it's simpler
to just go with what one is willing to type. IMO.