Sign in to follow this  

SERIOUS PROBLEM

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!!!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why are you posting this here when you already have the same post further down this forum?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this