On Mon, 13 Sep 2004 20:15:57 -0700, slyphiad wrote:
> i'm kinda new at c++ so be patient ^_^
>
> i was just wondering if u guys could help me to solve this problem
> that i had.
>
> i'm trying to create 5 sequential files using ofstream.
>
> this is what i did below:
> char filename[][13] =
^^ 1994 called. They want their code back.
> {"quest.01.cpp","quest.02.cpp","quest.03.cpp","que st.04.cpp","quest.05.cpp"};
>
> ofstream out(&filename);
>
> i've tried other stuff too but it doesnt seem too work.
> the only time, i can create file is when i do:
>
> ofstream out("quest.01.cpp");
>
> but this is so inefficient. i dont want to create 5 ofstream for to
> create 5 sequential files. is there anyway that i could solve this
> problem?
This is, in fact, exactly what you're going to have to do. The easiest
(and clearest) way would be to do it in a loop.
// Define appropriate constant somewhere, i.e.,
// const unsigned NUM_FILES = 5;
for (unsigned i = 0; i < NUM_FILES; ++i) {
std:

fstream out (filename[i]);
/* whatever output goes into each file */
out.close ();
}
--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.