Reposition gotoxy(x, y) with C

Asked

Viewed 105 times

1

I’m using the gotoxy function, so I can write in a certain coordinate:

#include <stdio.h>
#include <windows.h> 

void gotoxy(int x, int y){
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1});
}

main(){
    #chamando a função
    gotoxy(40, 20);
    printf("testando");
}

The function positions and writes normally at the coordinate, but when using another printf("\ntestando"), the text is written from the line chosen in the function, in the case of the example, in line 21.

  • Is there any way to return to the line that was initially, when the function was called?

  • When using a coordinate repositioning function, the writing control of the program is lost?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.