ifstream

V

vsgdp

Hello,

Suppose I use one ifstream object for the life of a program.

If the user opts to load/save I call

inFile.open(...);

....

inFile.close();

Whenever the menu item is selected.

However, this does not work. I was able to get it to work by calling:

inFile.close();
inFile.clear();

But my question is, why must I call the clear method?
 
V

Victor Bazarov

vsgdp said:
Suppose I use one ifstream object for the life of a program.

If the user opts to load/save I call

inFile.open(...);

...

inFile.close();

Whenever the menu item is selected.

However, this does not work. I was able to get it to work by calling:

inFile.close();
inFile.clear();

But my question is, why must I call the clear method?


Usually because you cause it to become bad somehow, like an attempt to
read beyond its end...

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top