转到C ++中的控制台位置(在OSX上)

问题描述 投票:2回答:1

我有这段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;
}
c++ macos console-application
1个回答
4
投票

使用nCurses库(推荐),或使用ANSI转义序列:

// nCurses, you need to initialize the window before
move(x, y);
// ANSI escape seq
printf("\033[%d;%dm", x, y);
© www.soinside.com 2019 - 2024. All rights reserved.