Remove blinking underscore on console / cmd prompt

前端 未结 1 1214
别那么骄傲
别那么骄傲 2020-12-28 20:04

This probably something very simple, but Google doesn\'t seem to have the answer. Is there a simple command for a console program to stop the blinking cursor? Before my prog

相关标签:
1条回答
  • 2020-12-28 20:30

    You can hide the cursor by calling SetConsoleCursorInfo. .

    #include <windows.h>
    
    void ShowConsoleCursor(bool showFlag)
    {
        HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
    
        CONSOLE_CURSOR_INFO     cursorInfo;
    
        GetConsoleCursorInfo(out, &cursorInfo);
        cursorInfo.bVisible = showFlag; // set the cursor visibility
        SetConsoleCursorInfo(out, &cursorInfo);
    }
    
    int main()
    {
        ShowConsoleCursor(false);
        system("pause");
    }
    
    0 讨论(0)
提交回复
热议问题