quick question, I am on my 4th book and i am compiling a few examples out of Chapter 1 but not getting correct results. The program is not counting lines. For example:
Code:
#include <stdio.h>
main()
{
int c, n1;
n1 = 0;
while (( c = getchar()) != EOF)
if ( c == '\n')
++n1;
printf("%d\n", n1);
}
and also,...
Code:
#include <stdio.h>
/* count charcters in input; 1st version */
main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}
I am compiling them using CLANG 6.0.0 on freebsd 11.2. They compile however am not giving me total char count...just another empty blank line. THANKS!