Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (9.5k points)

Here’s my code below for the snake game loop in C which works in Codeblocks:

int ResetScreenPosition() {

HANDLE hOut;

COORD Position;

hOut = GetStdHandle(STD_OUTPUT_HANDLE);

Position.X = 0;

Position.Y = 0;

SetConsoleCursorPosition(hOut,Position);

}

Can anyone tell me how to make the cursor go back to position(0,0) which makes the loops go on in Linux with text editor vim? 

1 Answer

0 votes
by (19.7k points)

To set the cursor position to coordinate 0,0, see the code below: 

void ResetScreenPosition(void){

     printf("\033[%d;%dH", 0, 0);

}

 If you want to learn more about Linuxthen go through this Linux tutorial by Intellipaat for more insights.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...