简体   繁体   中英

how to set cursor position to its default

I have used gotoxy() function to set cursor position to specific points that help me to reorder the values as shown in picture . Now I want the "press any key to continue" statement and the referred zero value to be set at the bottom of the screen how I can do this

在此处输入图片说明

Here is the code for gotoxy() function:

void gotoxy(int x, int y) 
{ 
COORD coord;
coord.X = x; 
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

You can get the current position using GetConsoleScreenBufferInfo .

Something like:

COORD GetXY()
{
    CONSOLE_SCREEN_BUFFER_INFO info;
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
    return info.dwCursorPosition;
}

It appears that your gotoxy() works.

So simply set the cursor to "top left" of the screen (or to your favorite location?) prior to prompting for "press any key to continue".

You own the cursor!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM