SERIOUS PROBLEM

Started by
2 comments, last by Conner McCloud 17 years, 8 months ago
Hey Guys, I had some sort of a problem while using the "filename.eof()" command mingw. the program never return a "true" value (or '1') when I use eof() so I cannot read a file using the eof condition. I have tried both the while(!infile.eof()) { } and if(infile.eof != 1) { } I even tried this... I had a single word in my file.. ********** Booom!!! ********** but when i did this: infile >> one; infile >> two; cout << infile.eof() the putput was still 0 when i anticipated a 1 as output I did compiled this source using mingw #include<iostream> #include<stdlib.h> #include<string> #include<fstream> using namespace std; int main(int argc, char *argv[]){ string part, full; ofstream outfile("boom.dat"); outfile << "BOOM"; outfile.close(); ifstream infile("boom.dat"); infile >> part; cout << part; infile >> part; cout << infile.eof(); infile >> part; cout << infile.eof(); infile >> part; cout << infile.eof() << part; infile.close(); return 0; } and the output was : BOOM000BOOM but how once I reached the end of file (since the BOOM was the only word, once I read the file again the eof value should be 0 again!! PlEASE HELP!!!!
Advertisement
Why are you posting this here when you already have the same post further down this forum?
dude could you consider givin me a solution instead i tried everything I could even the one the guy replied in my other tab
Quote:Original post by Abhinash
dude could you consider givin me a solution instead i tried everything I could even the one the guy replied in my other tab

Why should we consider giving you a solution when you won't consider sticking to one thread at a time?

CM

This topic is closed to new replies.

Advertisement