Overloaded file

May 23, 2013 at 7:22pm
closed account (NUj6URfi)
I used fstream and opened and closed files. I did this so much I overloaded the function. I have many subroutines and need to constantly open and close the file. How can I do this?
May 23, 2013 at 7:55pm
You might want to take a step back. Why are you opening and closing the file so much. There's a lot of overhead to do that all the time. It is probably better to have it opened once and keep that handle available for later use.

If you still want to do what you are doing, then you need to give us a clearer understanding of what you are attempting to do. Writing an example to show this would probably help.
May 23, 2013 at 7:55pm
I don't understand you.
Try to reword it and put some examples.
Also, ¿couldn't you open the file just one time?
May 23, 2013 at 8:29pm
closed account (NUj6URfi)
No because when you call a function you have to reopen the file.
May 23, 2013 at 8:33pm
The question is why do you have to reopen the file at every function call? This seems very unnecessary.

Show examples.
May 23, 2013 at 8:37pm
closed account (NUj6URfi)
It doesn't work otherwise.
May 23, 2013 at 8:40pm
closed account (NUj6URfi)
Tried my 2nd compiler and it worked. Thnx everyone.
Topic archived. No new replies allowed.