C语言 时间显示
程序员文章站
2024-01-21 21:01:04
...
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>
/** 隐藏光标 */
void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
int main()
{
while(1)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
//打印时间
printf ( "The current date/time is: %s", asctime (timeinfo) );
HideCursor();
Sleep(1000); // 睡眠1s
system("cls"); //清屏
}
return 0;
}
下一篇: DOS之del命令