这里直接使用了 localtime 函数获取 tm 时间然后做显示。代码如下:
#include <iostream>
#include <windows.h>
#include "time.h"
#include <process.h>
using namespace std;
void Clock()
{
struct tm *ptr;
time_t lt = time(NULL);
ptr = localtime(<);
cout<<"It is--- ";
cout.setf(ios::right);
cout.width(2);
cout.fill('0');
cout<<ptr->tm_hour;
cout<<":";
cout.setf(ios::right);
cout.width(2);
cout.fill('0');
cout<<ptr->tm_min;
cout<<":";
cout.setf(ios::right);
cout.width(2);
cout.fill('0');
cout<<ptr->tm_sec;
cout<<" ---now."<<endl;
}
int main()
{
while(true)
{
system("cls");
Clock();
Sleep(1000);
}
return 0;
}
博客介绍了直接使用localtime函数获取tm时间并进行显示的操作,信息技术相关内容聚焦于该函数在时间获取与显示方面的应用。
310

被折叠的 条评论
为什么被折叠?



