gotoxy! what’s that?
gotoxy was one of my favorite functions in turbo c++, it moves the input cursor in a console application/MS-DOS application from one location to another.
So is there an equivalent function in a windows console application which does the same? Yes, it’s called SetConsoleCursorPosition.
Sample code
As always with me here is a function which does this!
BOOL gotoxy( const WORD x, const WORD y )
{
COORD xy;
xy.X = x;
xy.Y = y;
return SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), xy );
}
int main()
{
if( !gotoxy( 10, 10 ))
{
std::cout < < "gotoxy failed :(, seems like coords are too big\n";
return 1;
}
return 0;
}[/sourcecode]
Result of calling "gotoxy", see how the pause message has shifted down and to the right.