Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   quries (http://www.go4expert.com/forums/quries-t10688/)

answerme 21May2008 19:26

quries
 
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 );
}


mr.anandc 23May2008 10:51

Re: quries
 
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.


All times are GMT +5.5. The time now is 13:49.