I was attempting to read a file as such:
char c;
while ((c = fgetc(fp) != EOF)) { ... }
And was not stepping into the loop. Why doesn't this code work?
I realized the error was failing to place the wrapping parenthesis before the not equals comparison to EOF, as such:
char c;
while ((c = fgetc(fp)) != EOF) { ... }
However, I don't understand why the first conditional doesn't work. I tested it with
printf("%d", c = fgetc(fp) != EOF), and that returns 1. So the issue must be something to do with the conditional being wrapped inside of (...) parenthesis, which would seem to make it be evaluating to while ( (1) ).
I bet I am misunderstanding RE: the operator association order, but do not know for certain the root of the error here.