//获取系统时间和名字
time_t rawtime;
tm ptminfo;
time(&rawtime);
localtime_s(&ptminfo, &rawtime);
char fileName[256];
sprintf_s(fileName, "..\\日志\\日志%02d%02d%02d%02d%02d%02d.txt",
ptminfo.tm_year + 1900, ptminfo.tm_mon + 1, ptminfo.tm_mday,
ptminfo.tm_hour, ptminfo.tm_min, ptminfo.tm_sec);
int error = fopen_s(&m_file, fileName, "w");
//写
char buffer[256] = "123456";
fwrite(buffer, 1, sizeof(buffer), m_file);
//退出
int error = fclose(m_file); //注意:该函数会释放m_file空间,如果再delete m_file;会出错
C++随手笔记(十三) FILE使用
于 2022-08-14 17:16:00 首次发布