.eof() is not working in turbo c++ -
myfile.eof()
not working in turbo c++
. here fragment:
while(viofile >> vio.studnumb >> vio.firstname >> vio.lastname >> vio.code >> vio.remarks >> vio.date >> '/`enter code here`' >> vio.month >> '/'>>vio.year >> "noted by:" >> vio.filler >> vio.position >> vio.user) { if(vio.studnumb==studno) { cout << endl << studno << ' ' << vio.firstname << ' ' << vio.lastname << ' '<< endl; cout << "violation :" << vio.code << ' ' << vio.remarks << ' ' << vio.date << '/' << vio.month<< '/' << vio.year <<endl; cout << " noted by: " << vio.positio`enter code here`n << ' '; cout <<vio.user; break; } else if(viofile.eof()) cout << "you have no violation.\n"; }
i have project finish. please reply.
thank you.
if call operator>>
reaches end of file, eofbit
set , stream convert false in boolean context. @ point program drop out of loop. if execution made loop, (bool)viofile
still true, , viofile.eof()
can't possibly return true.
use boolean flag - set false before loop, set true when print violation. after loop, if flag still isn't set, haven't printed , violations, can report accordingly.
Comments
Post a Comment