As with my previous question this is also some confusion about an example or two from K&R. Both of these programs are supposed to produce the same answers and I can follow the code easily enough but when I run the program it doesn't print the results. I am guessing that it is supposed to print the no. of characters that I input.
Program 1:
Program 2:Code:#include <stdio.h> main() { long nc; nc = 0; while (getchar() != EOF) ++nc; printf("%ld\n", nc); }
Why would they not print? Or is my assumption that they should print something wrong?Code:#include <stdio.h> main() { double nc; for (nc = 0; getchar() != EOF; ++nc) ; printf ("%.0f\n", nc); }