커서 움직이기
페이지 정보
본문
#include<stdio.h>
#include<windows.h>
#include <conio.h>
main()
{
int x,y;
int ch;
x=40;
y=10;
system("cls");
for(;;) {
gotoxy(x,y);
putch('#');
ch=getch();
if (ch == 0xE0 || ch == 0) {
ch=getch();
switch (ch) {
case 75:
x=x-1;
break;
case 77:
x=x+1;
break;
case 72:
y=y-1;
break;
case 80:
y=y+1;
break;
}
} else {
switch (ch) {
case ' ':
system("cls");
break;
case 'q':
case 'Q':
exit(0);
}
}
}
getch();
}
gotoxy(int x, int y)
{
COORD pos={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
#include<windows.h>
#include <conio.h>
main()
{
int x,y;
int ch;
x=40;
y=10;
system("cls");
for(;;) {
gotoxy(x,y);
putch('#');
ch=getch();
if (ch == 0xE0 || ch == 0) {
ch=getch();
switch (ch) {
case 75:
x=x-1;
break;
case 77:
x=x+1;
break;
case 72:
y=y-1;
break;
case 80:
y=y+1;
break;
}
} else {
switch (ch) {
case ' ':
system("cls");
break;
case 'q':
case 'Q':
exit(0);
}
}
}
getch();
}
gotoxy(int x, int y)
{
COORD pos={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
댓글목록
등록된 댓글이 없습니다.