I try to write my data into two different files and i just use something like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
ofstream myfile;
myfile.open("phase 1.txt");
if (myfile.is_open())
{
for(i=0;i<M; i++)
{
myfile<<arrayD[j][10*i];
myfile<<",";
}
return 0;
myfile.close();
}
ofstream myfile1;
myfile1.open("phase 2.txt");
if (myfile1.is_open())
{
for(i=0;i<M; i++)
{
myfile1<<arrayD[j][10*i];
myfile1<<",";
}
return 0;
myfile1.close();
}
|
But it only generate the first file. Anyone know the reason, how should i modify this? Any help is appreciated.
Last edited on
I think you don't need the
ofstream myfile1
just re-use myfile
still only generate 1 file...
do you have #include <fstream>?
you should also do
myfile.open("phase 1.txt", fstream::in | fstream::app);