当前位置首页 > 百科> 正文

coord

2019-09-28 01:16:27 百科

coord

COORD是Windows API中定义的一种结构,表示一个字元在控制台萤幕上的坐标。其定义为:

typedef struct _COORD {

SHORT X; // horizontal coordinate

SHORT Y; // vertical coordinate

} COORD;

基本介绍

  • 外文名:coord
  • 出处:Windows API
  • 表示:一个字元在控制台萤幕上的坐标
  • 所属学科:软体

定义

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);
}
声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:baisebaisebaise@yeah.net