#include <bits/stdc++.h> #include <windows.h> #include <conio.h>//控制台输入输出头文件 using namespace std; int main(){ HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);//获取标准输出的句柄 COORD coord={0,0};//保存光标坐标 SetConsoleCursorPosition(handle,coord); cout<<"HH"; while(1){ if(kbhit()){ SetConsoleCursorPosition(handle,coord); cout<<" "; int key=getch(); switch(key){ case 72: coord.Y--;break; case 75: coord.X--;break; case 77: coord.X++;break; case 80: coord.Y++;break; default: break; } } SetConsoleCursorPosition(handle,coord); cout<<"HH"; } return 0; }
标签:handle,输入输出,coord,HANDLE,控制台,include From: https://www.cnblogs.com/fushuxuan/p/18132887