c语言的ofstream能不能一次创建多个不重名的文件?要代码简单些的,蟹蟹!
首先,你的基本概念就是错的,c语言根本没有ofstream的,它是C++,且C与C++根本就不是同一语言
其次,你的这个可以用循环实现
若不考虑文件后面的操作,以下程序可算成1.txt~100.txt其100个文件
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
stringstream ss;
for(int i=1;i<=100;i++)
{
ss.str("");
ss << i << ".txt";
ofstream(ss.str().c_str());
}
return 0;
}
热门标签: