Sorry for late reply.
So, firstly, you have to include the
<windows.h>
header file in order to be able to use the specific console functions and variables: "
HANDLE, COORD, GetStdHandle, SetConsoleCursorPosition |
".
Now, what your own defined function is doing is actually having you get the control over the "console" via
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE) ;
. Now that you gained control over it, you declare your cursor position as a COORD structure with two parameters X, and Y (where X represents the column and Y the line).
SetConsoleCursorPosition( hStdout, position ) ;
is the function that actually gives you the full control on the cursor position. It takes two arguments: the first is the variable which holds control on the console window and the second is the coordinate x,y pair.
Actually,
gotoxy();
is a function that exists in C, but it wasn't implemented in the official C++ libraries. Thus, using the already existing implemented functions you can create your own
gotoxy();
function.
For further details about this function I recommend reading on Microsoft Windows' website.
As about using it in Linux, I am sorry but I am quite sure it won't work. I only program over Windows and I have been using this function. Maybe asking on the UNIX/Linux section of the forum and posting a link to this topic might get you to the answers you are looking for.
Glad I could help.
~ Raul ~