如何将系统时间作为文件名
用法如下:
#include char s[30]; struct tim; time_t now; now = time(NULL); tim = *(localtime(&now)); strftime(s,30,"_%Y_%b_%d_%H_%M_%S.txt",&tim); string path = string(s); std::ofstream file; file.open(path.c_str(),ios::trunc|ios::out); //表示覆盖原来的文件内容 file<<"***"<<"\n"; file.close(); ...