gotoXY 显示在屏幕上
gotoXY display on the screen
我知道我的问题很愚蠢,但我仍然需要你的 help.why gotoxy 功能不起作用吗?
void gotoxy(int x,int y)
{
COORD coord={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
using namespace std;
int main()
{
cout<<"___________________________________________________________________________________________________________________________\n";
cout<<"| | XUAT SAC | GIOI | KHA | TRUNG BINH | YEU |\n";
cout<<"| MA LOP |--------------------------------------------------------------------------------------------------------|\n";
cout<<"| | SL | % | SL | % | SL | % | SL | % | SL | % |\n";
cout<<"|-------------------------------------------------------------------------------------------------------------------------|\n";
gotoxy(0,5);cout<<"gotoxy(0,5)";
}
显示的是:
___________________________________________________________________________________________________________________________
| | XUAT SAC | GIOI | KHA | TRUNG BINH | YEU |
| MA LOP |--------------------------------------------------------------------------------------------------gotoxy(0,5)
I want to gotoxy(0,5)on the screen but it is display in the line of 3
I want to gotoxy(0,5)on the screen but it is display in the line of 3
不对,实际上显示在第5行
我平台上的默认控制台宽度是 120 像素。当打印的行太长无法适应 120 像素的限制时 windows 控制台将自动创建一个新行,因此 Y=Y+1。
此代码很可能适合您,因为宽度较短...
std::cout << "_____________________1\n";
std::cout << "_____________________2\n";
std::cout << "_____________________3\n";
std::cout << "_____________________4\n";
std::cout << "_____________________5\n";
gotoxy(0, 5);
cout << "gotoxy(0,5)";
您可以将控制台宽度调整到更宽的长度,它应该可以正常工作。
https://www.howtogeek.com/howto/19982/how-to-make-the-windows-command-prompt-wider/
我知道我的问题很愚蠢,但我仍然需要你的 help.why gotoxy 功能不起作用吗?
void gotoxy(int x,int y)
{
COORD coord={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
using namespace std;
int main()
{
cout<<"___________________________________________________________________________________________________________________________\n";
cout<<"| | XUAT SAC | GIOI | KHA | TRUNG BINH | YEU |\n";
cout<<"| MA LOP |--------------------------------------------------------------------------------------------------------|\n";
cout<<"| | SL | % | SL | % | SL | % | SL | % | SL | % |\n";
cout<<"|-------------------------------------------------------------------------------------------------------------------------|\n";
gotoxy(0,5);cout<<"gotoxy(0,5)";
}
显示的是:
___________________________________________________________________________________________________________________________
| | XUAT SAC | GIOI | KHA | TRUNG BINH | YEU |
| MA LOP |--------------------------------------------------------------------------------------------------gotoxy(0,5)
I want to gotoxy(0,5)on the screen but it is display in the line of 3
I want to gotoxy(0,5)on the screen but it is display in the line of 3
不对,实际上显示在第5行
我平台上的默认控制台宽度是 120 像素。当打印的行太长无法适应 120 像素的限制时 windows 控制台将自动创建一个新行,因此 Y=Y+1。
此代码很可能适合您,因为宽度较短...
std::cout << "_____________________1\n";
std::cout << "_____________________2\n";
std::cout << "_____________________3\n";
std::cout << "_____________________4\n";
std::cout << "_____________________5\n";
gotoxy(0, 5);
cout << "gotoxy(0,5)";
您可以将控制台宽度调整到更宽的长度,它应该可以正常工作。
https://www.howtogeek.com/howto/19982/how-to-make-the-windows-command-prompt-wider/