我有这段c ++代码在Windows上完美运行,但我正在尝试将其移植到OSX并获得大量编译错误。
是否有OSX的等效库?
#include <windows.h>
void gotoXY(int x, int y)
{
//Set the coordinates
COORD coord = {x, y};
//Set the position
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
return;
}
使用nCurses库(推荐),或使用ANSI转义序列:
// nCurses, you need to initialize the window before
move(x, y);
// ANSI escape seq
printf("\033[%d;%dm", x, y);