pez
August 10th, 2006, 01:19 PM
Hi, I was wondering if someone could tell me why I am having problems with this code:
#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}
gcc -o test test.c
./test
I inputted 'test' and hit enter but all that happens is do a carriage return and doesn't represent EOF.
I'm banging my head here!
#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}
gcc -o test test.c
./test
I inputted 'test' and hit enter but all that happens is do a carriage return and doesn't represent EOF.
I'm banging my head here!