// 使用window api 获得系统时间 // 生成 #include "stdafx.h" #include <Windows.h> #include <direct.h> #include <iostream> int main() { SYSTEMTIME sys; GetLocalTime(&sys); printf("%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d ", sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, sys.wDayOfWeek); // 使用时间作为文件夹名字 char char_folder_names[50] = {}; sprintf_s(char_folder_names, 50, "result_%4d%02d%02d_%02d%02d%02d_xxx", sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond); // 补全文件夹路径名,生成 std::string floder_full_path("C:\" + std::string(char_folder_names)); _mkdir(floder_full_path.c_str()); return 0; }