0

Can anybody say what does this mean while(! File. eof())

11th Oct 2017, 1:38 PM
ashish
5 Réponses
+ 6
The not operator is used to run the loop only till the EOF is not encountered. If we don't see EOF, it means we have more data in the file to be read. So we continue reading. You see, file.eof() returns true when EOF is read.
11th Oct 2017, 2:10 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 5
It just checks whether we have reached the End-Of-File(EOF) character in a file or not. The EOF character is used to mark the end of a text/binary file. All I/O must stop after this, thus we use eof().
11th Oct 2017, 2:05 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
Yes, thats it. You have understood it.
11th Oct 2017, 2:29 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
eof returns false until end of the file is detected, so to make the condition of while loop correct not operator is used to run the loop.... Did i get it right?
11th Oct 2017, 2:18 PM
ashish
+ 2
Thank you for your answer. But what is the use of not operator '!' it can be simply written as while(file.eof())
11th Oct 2017, 2:08 PM
ashish