#include<stdio.h>
#include<windows.h>
#define up 72
#define down 80
#define left 75
#define right 77
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
char key;
int x,y,c=0;
x=10;
y=10;
gotoxy(x,y);
printf("*");
while(1)
{
if(kbhit())
{
gotoxy(x,y);
printf(" ");
c++;
key = getch();
switch(key)
{
case up:
y--;
if(y<5)
{
y=5;
}
break;
case down:
y++;
if(y>15)
{
y=15;
}
break;
case left:
x--;
if(x<5)
{
x=5;
}
break;
case right:
x++;
if(x>15)
{
x=15;
}
break;
}
gotoxy(x,y);
printf("*");
}
}
return 0;
}