COORD是Windows API中定义的一种结构,表示一个字元在控制台萤幕上的坐标。其定义为:
typedef struct _COORD {
SHORT X; // horizontal coordinate
SHORT Y; // vertical coordinate
} COORD;
typedef struct _COORD {SHORT X; // horizontal coordinate
SHORT Y; // vertical coordinate
} COORD;
表示一个字元在控制台萤幕上的坐标。套用c++中的例子:#include <iostream>#include <Windows.h>using namespace std;void gotoxy(int x,int y){COORD loc={x,y};HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOutput,loc);}int main(){gotoxy(2,0);cout<<"Hello World!"<<endl;system("pause");return 0;}=============输出结果为(下划线表示此处无字元,)==============__Hello World!请按任意键继续…==========================================================C中的例子:void Pos(int x, int y){COORD pos;HANDLE hOutput;pos.X = x;pos.Y = y;hOutput = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOutput, pos);}
本文发布于:2023-03-25 21:06:35,感谢您对本站的认可!
本文链接:http://www.ranqi119.com/to/1679922190237451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |