Joke Collection Website - News headlines - C language problem: DOS cursor positioning! ! ! Wait online! ! !

C language problem: DOS cursor positioning! ! ! Wait online! ! !

C language has gotoxy(x, y) function to locate cursor position;

But there is no conio.h in VC, so there is no gotoxy (), which only exists in TC and BC.

Here's what others built:

Include & ltwindows.h & gt

# include & ltiostream & gt

Use namespace std

void go toxy(int x,int y ){

Coordinate c;

c.x = x- 1;

c.y = y- 1;

SetConsoleCursorPosition(GetStdHandle(STD _ OUTPUT _ HANDLE),c);

}

int main()

{

Getuosi (20,12);

std::cout<。 & lt "Hello world!" & lt& ltendl

Returns 0;

}

COORD and SetConsoleCursorPosition are defined in wincon.h ~

SetConsoleCursorPosition is used to set the cursor position on the corresponding device. These two parameters are the device handle and the cursor position structure. GetStdHandle is defined on winbase.h and is used to obtain standard input, output and error output handles.

When the parameter is identified as STD_OUTPUT_HANDLE, the standard output handle is obtained.