不知写啥好

Raymond_R 2026-10-20 21:32:48

#include #include #include <windows.h>

void gotoxy(int x, int y) { COORD pos; pos.X = x; pos.Y = y; HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOut, pos); }

void hideCursor() { CONSOLE_CURSOR_INFO cursor_info; cursor_info.dwSize = 1; cursor_info.bVisible = FALSE; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); }

int main() { hideCursor(); while (1) { time_t now = time(NULL); tm* t = localtime(&now);

    gotoxy(0,0);
    printf("====================\n");
    printf("当前时间:%04d-%02d-%02d %02d:%02d:%02d\n",
        t->tm_year + 1900,
        t->tm_mon + 1,
        t->tm_mday,
        t->tm_hour,
        t->tm_min,
        t->tm_sec);
    printf("====================\n");

    Sleep(900);
}
return 0;

}