#include <iostream>
#include <ctime>
using namespace std;
int main()
{
time_t now;
struct tm *fmt;
time(&now);
fmt = localtime(&now);
cout<<fmt->tm_year+1900<<" "<<fmt->tm_mon+1<<" "<<fmt->tm_mday<<" ";
cout<<fmt->tm_hour<<" "<<fmt->tm_min<<" "<<fmt->tm_sec<<endl;
return 0;
}
c++自动获取当前时间,并分别用整形输出
最新推荐文章于 2024-08-27 15:39:32 发布