ifstream question

If I am continually opening and closing a file in a program is there a way to take note of where the program was closed and continue on later???

ifstream input;
do{
input.open("data.txt")
input<< x;
input<< y;
input.close()
..
..
..
input.open("data.txt")}while(!input.eof());
Not easily...why would you need to do that anyway?
I need to open another ifstream and I am very weary of trying to open two ifstreams. If I remember correctly you can't even do that.
Where did you get that impression? You need a seperate ifstream for each file but you most certainly can open more then one at a time.
I'm sorry I stated that out of context. I need to use a file as both a ifstream and an ofstream. This is were I have become confused because I don't believe you can do both at the same time.
Try at fstream, it supports both operations. Although I do have to ask, why do you need to do this??
I agree, a better method would be to read the data into an array, forget about the file and work with it from there. Then you just dump the data to the file when you're done with it. Hitting the disk is always TDS.
Last edited on
Topic archived. No new replies allowed.