c++ 打印时间

 

https://blog.csdn.net/u011288190/article/details/45722925

 

输出麻烦, 改造一下:

#include<iostream>
#include<time.h>
#include<stdio.h>

using namespace std;

int main()
{
    time_t currentTime;
    time(&currentTime);
struct tm *p = localtime(&currentTime); char str[200] = {0}; snprintf(str, 200, "Hour:%d, minit: %d, second: %d", p->tm_hour, p->tm_min, p->tm_sec); cout << str<< endl; }

 

posted @ 2020-11-16 10:34  哈哈不是嘎嘎  阅读(583)  评论(0编辑  收藏  举报