I am trying to scan file by using while loop:
while(feof(src_file) == 0){
}
This method works perfectly fine if there is only one row in scanned file. Otherwise, I get an endless loop. Why is that and how to fix this issue?
I am trying to scan file by using while loop:
while(feof(src_file) == 0){
}
This method works perfectly fine if there is only one row in scanned file. Otherwise, I get an endless loop. Why is that and how to fix this issue?
http://www.cplusplus.com/reference/cstdio/feof/ as this says the error is cleared by some api calls a better check is fgetc(src_file) != EOF
feof()
is used to help determine the cause of the last read error. It returns "true" if the last read error was due to the file having reached the end.
If there wasn't a previous read error, calling feof()
is kinda meaningless.