By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,529 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,529 IT Pros & Developers. It's quick & easy.

Redifinition of fstream

P: 3
Hi,

I want to open & close multiple files in a for loop.I have two problems :

1.How can I define an array of file names to be entered to "fstream" function?

2.How can I avoid redefiniton error for redefining an fstream variable?

I would be thankful if any one can help me.
Jul 9 '07 #1
Share this Question
Share on Google+
2 Replies


kky2k
P: 34
Hi,

I want to open & close multiple files in a for loop.I have two problems :

1.How can I define an array of file names to be entered to "fstream" function?

2.How can I avoid redefiniton error for redefining an fstream variable?

I would be thankful if any one can help me.
Read the guidelines before posting...
Jul 9 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Have you considered creating a vector<fstream> files???

You could create an fstream variable and open it as File 1 then do a push_back() in to the vector.

Use the same variable to open File 2 and push_back() again to the vector.

Then just use files[i] to reference a particular fstream.
Jul 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.