gotoxy 在c++中怎么用啊 ,通不过啊

来源:百度知道 编辑:UC知道 时间:2024/07/02 21:15:27

turboc里面可用
但是vc里面没有这个函数 要自己做
比如 清屏:

void clrscr(int lines)
{
int s;
COORD c={0,0};
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
//c.X=c.Y=0;
DWORD dwL;
TCHAR tc=32;
CONSOLE_SCREEN_BUFFER_INFO inf;
GetConsoleScreenBufferInfo(h,&inf);
if (lines<0) lines=inf.dwSize.Y; else {
if (inf.dwSize.Y < lines) lines=inf.dwSize.Y;
}
s=inf.dwSize.X * lines;
FillConsoleOutputCharacter(h,tc,s,c,&dwL);
SetConsoleCursorPosition (h,c);

}

gotoxy:

void gotoxy(int x,int y)
{
COORD c;

c.X=x;c.Y=y;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE),c);

}

改颜色函数:

void setcolor(int fg,int bg)
{
WORD wc;
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
bg<<=4;
wc=(fg & 0x000f )|(bg & 0x00f0);

SetConsoleTextAttribute(h,wc);
}