Reputation: 23497
I have this piece of c++ code which works perfectly on Windows but I'm trying to port it to OSX and getting a lot of compilation errors.
Is there an equivalent library for 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;
}
Upvotes: 3
Views: 2460
Reputation: 37237
Either use nCurses library (recommended), or use ANSI escape sequence:
// nCurses, you need to initialize the window before
move(x, y);
// ANSI escape seq
printf("\033[%d;%dm", x, y);
Upvotes: 6