C Cursor Position: gotoxy Function Guide
In the C language, the gotoxy function can be used to position the cursor. Here is a simple example code:
#include <stdio.h>
void gotoxy(int x, int y) {
printf("\033[%d;%df", y, x);
}
int main() {
int x = 10;
int y = 5;
gotoxy(x, y);
printf("Hello, World!\n");
return 0;
}
In this example, the gotoxy function takes two parameters, which are the x and y coordinates to be located. By calling the gotoxy function, the cursor can be moved to the specified position and text can be outputted at that location. This achieves the effect of positioning the cursor in the console.