You should REALLY start enabling compiler warnings. They can help you find many bugs. Look here when I compile with -Wall
and -Wextra
.
$ gcc ba.c -Wall -Wextra
ba.c: In function ‘main’:
ba.c:13:5: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
while (nextChar != '\n' && nextChar != EOF);
^~~~~
ba.c:14:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
{
^
Remove the ;
after the while loop.
But there are other problems too. As you can see from when I corrected the indentation for you, the return 0
statement is inside the while loop. I assume that's not what you want.