If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Hello everyone,
I want to read strings from a file but the code I wrote doesn't seem to work. Every time I call the function I get my message "Reached end of file". It never enters the while loop and I don't understand why. The file is not empty. I should be able to get the string out of it, no?
The problem is that the wxTextFile loads the entire content of the file into memory, so when you start the loop, the wxFileInputStream has already reached its end.
2 thing you can do :
You don't have to use the wxFileInputStream : wxTextFile can read a real file itself
Use the wxTextFile Eof() function as your loop condition