c++获取系统时间
#include<ctime> #include<sstream> #include<iostream> using namespace std; int main() { time_t now = time(NULL); tm* t = localtime(&now); // 将信息输出到字符串流 stringstream ss; ss << t->tm_year + 1900 << "." << t->tm_mon + 1 << "." << t->tm_mday << ".." << t->tm_hour << "." << t->tm_min << "." << t->tm_sec; cout << "写入的文件为: " << ss.str() << endl;//字符串类型 return 0; }