1.判断是否有按键输入,获取输入的字符但不在命令行显示
#include <conio.h>
char key = 'D';
while (_kbhit())
{
key = _getch();
}
2.更新命令行中某个位置的字符
#include <windows.h>
COORD coord;
//更新末尾空格
coord.X = last_x;
coord.Y = last_y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
putchar(' ');
3.隐藏命令行光标
#include <windows.h>
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = 0;
cursor.dwSize = sizeof(cursor);
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor);