#include <stdio.h>
#include <windows.h>
#include <conio.h>

 

void gotoxy(int x, int y)
{
     COORD Cur;
     Cur.X=x;
     Cur.Y=y;
     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
int main()
{
    int x=40, y=12;
    int ch;
   
    for(;;){
    gotoxy(x,y);
    printf("*");
    ch=getch();
   
    if(ch==224){
    ch=getch();
   
    if(ch==72 || ch==80 || ch==75 ||ch==77){
    gotoxy(x,y);
    printf(" ");
    }
   
    if(ch==72 && y>0){
    y=y-1;
    }else if(ch==80 && y<24){       
    y=y+1;
    }else if(ch==75 && x>0){       
    x=x-1;
    }else if(ch==77 && x<79){        
    x=x+1;
    }
   
    }
    }
}