Why does the int variable nl evaluate to 33881 if you call a printf("%d",nl); after this the following line?
nl, nw, nc = 0;
How could it possibly evaluate to any other value than 0 before the loop? I am compiling with gcc from the terminal in a crouton/Ubuntu 12.04LTS environment on my ARM Chromebook, so I don't know if this is a bug in the code or my machine.
#include <stdio.h>
#define IN 1
#define OUT 0
main() {
int c, nl, nw, nc, state;
state = OUT;
nl, nw, nc = 0;
while ((c = getchar()) != EOF ) {
++nc;
if (c == '\n') {
++nl;
}
if (c == ' ' || c== '\n' || c== '\t') {
state = OUT;
} else if (state == OUT) {
state = IN;
++nw;
}
}
printf("%d %d %d\n", nl,nw,nc);
}
I tried adding another declarative line nl = 0; to force the program to return predictable values, but I still am no closer to understanding this behavior.
ìnt main(void)at least.