Okay, you type the EOF character on your keyboard, then come back and talk to us.
First off, main should ALWAYS return an int even if your compiler let's you get away with not returning it.
Second, I think this is what you're looking for:
Code:
#include <stdio.h>
int main(void)
{
int c ;
int count ;
count=0;
while ( ( c = getchar() ) != '\n' )
++count ;
printf( "%d characters\n" , count );
return 0;
}
Yay!
Code:
nouse@NeverlandRanch:~$ gcc count.c -o count
nouse@NeverlandRanch:~$ ./count
abcd
4 characters
nouse@NeverlandRanch:~$