首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

请教大家这个gotoxy函数没有用

2012-05-07 
请问大家这个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;

热点排行
Bad Request.