I have made a function that detects F1 key at the end of the program and starts it again. But what I wanted was that even if user is in the middle of the program when the user presses F1 it immediately restarts the program. Here is my code:
int key(void)
{
int key;
printf("\n");
key = getch();
key = getch();
if (key == 59)
system("cls");
}
int main()
{
my body.....
key(); // at the end of the body.
}
If I place the key() function call at the top of my body... It waits for the user to input F1 so that it can clear screen. I wanted to know how to make it global or an alternative way to make same process even though different code that if the user presses F1 it immediately restarts the program.