I am downloading content from a web source using URLDownloadToFile winapi function
All is well, with that, the content is downloaded to the correct path.

My probems start when I try to read it, like below, the loop never exits.


if (myReadFile.is_open()) 
           while (!myReadFile.eof()) 
cout << "done" << endl; // is never displayed

It has been working before, the only thing which has changed is the content of the web source
and perhaps it's encoding.

Appreciate any advice on this matter.

6 Years
Discussion Span
Last Post by Suzie999

The code you wrote is not reading the file.
Instead of MyReadFile.eof() do this, assuming MyReadFile is std::ifstream

std::string line;
while( getline(line, MyReadFile) )
   // blabla

Thanks Ancient Dragon.

I did have code there reading the file char by char, just was never reaching the end.

Seems it would not read it when there were either spaces, cr, lf and things like that.

I changed the websource in the end, I think it might have been something to do with unicode.

Cheers for advice.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.