Skip to main content
gamedev.net
🔒 Locked

weird ifstream problem

Started by jon723 2 replies 400+ views
Original Post
jon723
jon723
When I use ifstream to open a file then close it and then open the file again when i check the file pointer to see if it exists it always returns false. Here is an example: ifstream myfilehandle; myfilehandle.open("myfile.txt"); if(!myfilehandle) { return false; <-------- doesnt return false if the file exists } // do stuff with the file myfilehandle.close(); myfilehandle.open("myfile.txt"); <--------- open the same file a second time if(!myfilehandle) { return false; <---------- always returns false here }
www.lefthandinteractive.net
SiCrane
SiCrane
Try clearing the status bits before opening a new file (the .clear() member function).
jon723
jon723
Yup that solved the problem....thank you!!!!
www.lefthandinteractive.net
Zahlman
Zahlman
Let me offer the same advice I did here.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.