void gotoxy(int x, int y) { // printf("\033[%d;%dH", y, x); COORD V={x, y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), V); } void clrscr() { //Clear Screen // Refer: // https://zhuanlan.zhihu.com/p/415237147 HANDLE hdout = GetStdHandle(STD_OUTPUT_HANDLE); // Get standard output handler CONSOLE_SCREEN_BUFFER_INFO csbi; // Define screen buffer attribute variable GetConsoleScreenBufferInfo(hdout, &csbi); // Get screen buffer attribute variable DWORD size = csbi.dwSize.X * csbi.dwSize.Y, num = 0; // Define screen size COORD pos = {0, 0}; // initial left-top (0,0) coordinate // Fill the window as ' ' space to clear the buffer FillConsoleOutputCharacter(hdout, ' ', size, pos, &num); FillConsoleOutputAttribute (hdout, csbi.wAttributes, size, pos, &num ); SetConsoleCursorPosition(hdout, pos); // Set cursor to (0,0) }