How to implement this cycle with the OFStream function to change the name of the .txt file.
For example:
1 iteration: 1.txt file;
2 iteration: 2.txt file;
3 iteration: 3.txt file;
etc.
That is, how when you enter the path to the file to the file insert the variable
// Function ofstream Fout (“File 1.txt”);
Answer 1, Authority 100%
While you have not closed the file, it will not work out to rename it. Just close. Rename and re-open.
Rename via
int rename (const char * oldfilename, const char * newfilename);
If I do not correctly understand the question, then write in comments. Here is another solution as I understood:
for (int i = 1; i & lt; = 5; i ++) {
STD :: STRING FNAME = "FILE" + STD :: TO_STRING (I) + ". TXT";
FSTREAM FILE (FNAME.C_STR ());
// Work.
}