I want to get input from special position of console. I called my gotoxy
function to go to the specific position, then called gets
or scanf
to get input from that position.But the cursor waits for user input and do not input previous text the user has input. What is wrong with my code?
This is my code:
//suppose we are in position (0,0)
printf("%s","Hello world!\n");
//now we are in position (0,1)
gotoxy(0,0);
scanf("%s",string);//or gets(string)
Now string should be "Hello world!"
but it waits for user input.
My gotoxy:
void gotoxy(int x , int y){
COORD newPosition={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),newPosition);
}