void gotoxy(int x, int y)
{
HANDLE hout;
COORD coord;
coord.X = x;
coord.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, coord);
}
头文件为<Windows.h>. 运行截图
#include #include<Windows.h> using namespace std;
int main()
{
cout << "这是初始位置";
HANDLE hout;
COORD coord;
coord.X = 8;
coord.Y = 8;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, coord);
cout << "光标移动后位置";
system("pause");
return 0;
}