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.
As always with me here is a function which does this!
BOOL gotoxy( const WORD x, const WORD y )
xy.X = x;
xy.Y = y;
return SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), xy );
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.
Note that our gotoxy can fail if x or y is too big. A post from me will follow soon based on this function. It’s going to be about displaying a spining stick at the end of a progress message. You might have seen it if you have installed Linux.