C语言 时间显示

版权声明:https://blog.csdn.net/qq_37618797 https://blog.csdn.net/qq_37618797/article/details/82148373
#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;
}

猜你喜欢

转载自blog.csdn.net/qq_37618797/article/details/82148373
今日推荐