首先我们要为每一时间步,设置一个文件名:
char timestr[10] = "1"; itoa(time,timestr,10); std::string s; s += timestr; std::string path = "test_"+s+".txt";
这样传入的整型时间步,就可以添加到输出文件名中;
然后,输出文件:
std::ofstream out(path,std::ios_base::ate); std::ofstream out1(path1,std::ios_base::ate); int num[300]={ 0}; for(k=0;k
这里面,精简下来其实就是
std::ofstream out(path,std::ios_base::ate);out<<<" "< <<" "; for(i=0;i