Sign in to follow this  
Abhinash

SERIOUS PROBLEM

Recommended Posts

Abhinash    102
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   
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
Conner McCloud    1135
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
Guest
This topic is now closed to further replies.
Sign in to follow this