im new to c programming and im trying to learn it from "the c programming langauge" book and theres a little problem i dunno how to solve.
shouldnt this char counting program output nc only after EOF and not after every newline?? cause when i ran it, every time i pressed enter to a newline, it would show the value of nc, i mean shouldnt printf only be active only after EOF???Code:#include <stdio.h> main() { double nc; for (nc = 0; getchar() != EOF; ++nc) ; printf("%.0f\n", nc); getchar(); }
o and another thing, also the output comes out as many numbers, y isnt the ouput showing only 1 number of nc but showing every incrementing process??