#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main() {
ifstream ifs;
ifs.open("文件名称.txt", ios::in);
if (!ifs.is_open()) {
cout << "文件打开失败" << endl;
return 0;
}
string a[1000];
int i;
string buf;
for (i = 0; getline(ifs, buf); i++)
a[i] = buf + ".txt";
ofstream ofs;
for (int j = 0; j < i; j++) {
ofs.open(a[j], ios::out);
ofs << "/*" << endl;
ofs << "*/" << endl;
ofs << endl;
ofs.close();
cout << a[j] << "创建成功!" << endl;
}
return 0;
}
【C++】用C++批量创建txt文件
最新推荐文章于 2024-09-07 11:22:39 发布