Here is the code :
#include <stdio.h>
int main(void) {
int nextChar;
int numLines = 0;
while ((nextChar = getchar())!= EOF) {
if (nextChar == '\n') {
++numLines;
}
}
printf("The\nsky\nis\nblue\n");
printf("%d lines read.\n", numLines);
return 0;
}
It runs, but returns 0 lines read. I've tried putting the 'the sky is blue' text in a bunch of different places, but nothing seems to work.
The code was shown in the book, but without
printf("The\nsky\is\blue.\n");
but the output was shown as:
The
sky
is
blue.
4 lines read.
any suggestions??