怎样使c语言中运行界面的光标移至上一行?
1个回答
展开全部
turboc的
#include <stdio.h>
#include <conio.h>
int main()
{
int x, y;
gotoxy(5, 5);
printf("position: 5, 5");
x = wherex();
y = wherey();
getch();
gotoxy(x, y - 1);
getch();
}
控制台的
#include <windows.h>
#include <stdio.h>
#include <conio.h>
void gotoxy(HANDLE hOut, int x, int y);
void getxy(HANDLE hOut, int &x, int &y);
int main()
{
int x, y;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
gotoxy(hOut, 5, 5);
printf("position: 5, 5");
getxy(hOut, x, y);
getch();
gotoxy(hOut, x, y - 1);
getch();
CloseHandle(hOut);
}
void gotoxy(HANDLE hOut, int x, int y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hOut, pos);
}
void getxy(HANDLE hOut, int &x, int &y)
{
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hOut, &screen_buffer_info);
x = screen_buffer_info.dwCursorPosition.X;
y = screen_buffer_info.dwCursorPosition.Y;
}
#include <stdio.h>
#include <conio.h>
int main()
{
int x, y;
gotoxy(5, 5);
printf("position: 5, 5");
x = wherex();
y = wherey();
getch();
gotoxy(x, y - 1);
getch();
}
控制台的
#include <windows.h>
#include <stdio.h>
#include <conio.h>
void gotoxy(HANDLE hOut, int x, int y);
void getxy(HANDLE hOut, int &x, int &y);
int main()
{
int x, y;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
gotoxy(hOut, 5, 5);
printf("position: 5, 5");
getxy(hOut, x, y);
getch();
gotoxy(hOut, x, y - 1);
getch();
CloseHandle(hOut);
}
void gotoxy(HANDLE hOut, int x, int y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hOut, pos);
}
void getxy(HANDLE hOut, int &x, int &y)
{
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hOut, &screen_buffer_info);
x = screen_buffer_info.dwCursorPosition.X;
y = screen_buffer_info.dwCursorPosition.Y;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询