0
#include<stdio.h>
#include<conio.h>
#include<windows.h>
void gotoxy(short x, short y);    //here we declare the gotoxy function//
main()
int x=1,y=1;
{   
 gotoxy(x,y);                      //now where we want to call  gotoxy function //
 printf("*");

}
 return 0;
}
void gotoxy(short x, short y)           //definition of gotoxy function//                                               
{
 COORD pos ={x,y};
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);

this is what I have so far. but I'd like to make it so when I use the arrow keys, it would reposition itself by moving one space towards whichever the direction the key pressed is pointing

  • 1
    Well, you have `kbhit()` and `getch()` at your disposal. Function and cursor keys return 2 characters - an escaped value. – Weather Vane Dec 09 '19 at 17:55

1 Answers1

0

When using getch() the application halts until a key is pressed. See the link for usage with arrow keys. Then add or subtract from your global x and y variable depending on the arrow which was pressed. Then call gotoxy function. And please check your syntax before posting the question.