For example if I have this int type variable X that increment from 1 at the beginning to 10 when the program ends, how to open and write to 10 different files (data1.txt,data2.txt,data3.txt....) everytime X increments?
I've tried with the following but it didn't work:
string filename ("data");
int X;
ofstream out;
char number;
for(X=1;X<11;X++)
{
number=X;
filename+=number;
out.open(filename.c_str());
....
...writing....
out.close();
}