#include <bits/stdc++.h> #include <windows.h> #include <conio.h> //控制台输入输出文件 using namespace std; int main() { HANDLE handle =GetStdHandle(STD_OUTPUTHANDLE); //获取标准输出的句柄 COORD coord={0,0};//保存光标坐标 SetConsoleCursorPosition(handle,coord) cout<<"*"; 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<<"*"; } } return 0; }
标签:handle,GetStdHandle,句柄,coord,操作,控制台,include From: https://www.cnblogs.com/hanxuyao/p/18132902