Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef __unix__
- void gotoxy(short x,short y){
- printf("%c[%d;%df",0x1B,y,x);
- }
- #elif defined(_WIN32) || defined(_WIN64)
- #include <stdlib.h>
- #include <windows.h>
- short gotoxy(short x, short y)
- {
- COORD coord;
- CONSOLE_SCREEN_BUFFER_INFO csb;
- HANDLE h_stdout;
- if ((h_stdout = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE)
- return 0;
- if (GetConsoleScreenBufferInfo(h_stdout, &csb) == 0)
- return 0;
- x--;
- y--;
- if (x < csb.srWindow.Left || x > csb.srWindow.Right)
- return 0;
- if (y < csb.srWindow.Top || y > csb.srWindow.Bottom)
- return 0;
- coord.X = x;
- coord.Y = y;
- if (SetConsoleCursorPosition(h_stdout, coord) == 0)
- return 0;
- }
- #endif // defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement