gotoxy() for Visual C++

Hi. I'm writing a console application in Visual C++ and I need to change my cursor position, which I don't think is supported by any standard library.
Can someone please help me with the definition of a good gotoxy() function definition?
It's not a standard function so you need to get some library.
the curses library is often used for such things

You can move the cursor back using \r and \b
\r goes to the beginning of the line and \b goes back of one place
You can't go to previous lines with this
I've always used this function for changing the cursor position in the console.
But really, the console is a terrible medium for games

1
2
3
4
5
6
7
8
9
10
void gotoxy(int x, int y)
{
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	_COORD pos;
	pos.X = x;
	pos.Y = y;

	SetConsoleCursorPosition(hConsole, pos);
}
Topic archived. No new replies allowed.