请教大家这个gotoxy函数没有用
请问大家这个gotoxy函数没有用?程序如下:C/C++ code#include stdio.h#include stdlib.h#include wind
请问大家这个gotoxy函数没有用?
程序如下:
C/C++ code#include <stdio.h>#include <stdlib.h>#include <windows.h>void gotoxy(int x,int y){ COORD C; C.X = x; C.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),C);}int main(){ printf("Hello world!\n"); gotoxy(300,400); printf("Hello world!\n"); system("pause"); return 0;}
[解决办法]int main()
{
printf("Hello world!\n");
gotoxy(10,20);
printf("Hello world!\n");
system("pause");
return 0;
}
MSDN:The coordinates must be within the boundaries of the console screen buffer.
按照原先的300,400,检测SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),C)返回值为0;