DEV-C++怎么用gotoxy函数 5
gotoxy()只能在TC编译器下使用,但我用的是DEV-C++编译器,谁能讲下DEV-C++里面有什么函数可以实现gotoxy()函数的功能?或者能不能在TC编译器里的...
gotoxy()只能在TC编译器下使用,但我用的是DEV-C++编译器,谁能讲下DEV-C++里面有什么函数可以实现gotoxy()函数的功能?或者能不能在TC编译器里的图形库里找到gotoxy()函数看它怎么写的然后自己写一个,做个头文件??我找不到gotoxy()怎么写的,也不知道DEV-C编译器的那个函数能实现gotoxy()这个函数的功能,唉,有点啰嗦,还请各位大虾赐教。。
展开
2个回答
展开全部
控制台:清屏, gotoxy
#include <windows.h>
#include <stdio.h>
#include <string.h>
void Cls(HANDLE hConsole);
void gotoxy(HANDLE hOut, int x, iny y);
int main()
{
DWORD state = 0, res;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
Cls(hOut);
gotoxy(hOut, 5, 5);
printf("position: 5, 5\n");
CloseHandle(hOut);
}
void Cls(HANDLE hConsole)
{
COORD coordScreen = {0, 0};
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
bSuccess = FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten);
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
bSuccess = FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
bSuccess = SetConsoleCursorPosition(hConsole, coordScreen);
}
void gotoxy(HANDLE hOut, int x, iny y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hOut, pos); /* 设置光标位置 */
}
#include <windows.h>
#include <stdio.h>
#include <string.h>
void Cls(HANDLE hConsole);
void gotoxy(HANDLE hOut, int x, iny y);
int main()
{
DWORD state = 0, res;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
Cls(hOut);
gotoxy(hOut, 5, 5);
printf("position: 5, 5\n");
CloseHandle(hOut);
}
void Cls(HANDLE hConsole)
{
COORD coordScreen = {0, 0};
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
bSuccess = FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten);
bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
bSuccess = FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
bSuccess = SetConsoleCursorPosition(hConsole, coordScreen);
}
void gotoxy(HANDLE hOut, int x, iny y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hOut, pos); /* 设置光标位置 */
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询