quries

answerme's Avatar, Join Date: Dec 2007
Ambitious contributor
I have 2 queries
1. what this line means which is in bold
2.Up to how many times it will loop back
Code:
main()
{
int c ;
int count=0 ;

while ( ( c = getchar() ) != EOF )
   count ++ ;

printf( "%d characters\n" , count );
}
0
mr.anandc's Avatar, Join Date: May 2008
Go4Expert Member
1. what this line means which is in bold
while ( ( c = getchar() ) != EOF )

In this line, first getchar waits to for input from user and then the iput is assigned to "c ", and "c" value is compared against EOF.

2.Up to how many times it will loop back
In windows, getchar returns EOF when the iput is (ctrl + z). So it loop backs until (ctrl + z) is entered.

So, count prints, number of characters read so far.