I'm try to open certain file automatically in c++. File's title is same but only different file's number.
like this ' test_1.txt test_3.txt test_6.txt ... '
These numbers are not listed in regular sequence.
And here is my code
`
#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
using namespace std;
int main(){
int n[20]= {4,7,10,13,16,19,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
ifstream fp;
ofstream fo;
fp.open(Form("test%d.txt",n));
char line[200];
if(fp == NULL)
{
cout << "No file" << endl;
return 0;
}
if(fp.is_open())
{
ofstream fout("c_text%d.txt",n);
while (fp.getline(line, sizeof(line)))
{
if(line[4] == '2' && line[6] == '4')
{
fout<<line<<"\n";
}
}
fout.close();
}
fp.close();
return 0;
}`
Now, Function 'Form' doesn't work. and I don't have another idea. If you have any comment or idea, please tell me. Thank you!