I working on a quick time event using kbhit function where the user if he presses a specific key does one thing otherwise something else happens. I also wanted to add that if within a time limit the user doesn't click that key the program goes into the else. I wrote this, but it creates a loop. This is the code and if you could help me solve this problem, it would be a great pleasure.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <unistd.h>
int main()
{
printf("\nYou approach him, you try to take him by the legs from behind.\n");
Sleep(1500);
while (!kbhit())
{
printf("PRESS C !!!\n");
int c = getch();
if ((c == 'c' || c == 'C') && sleep(3) != 0)
{
printf("Can you pick him up by the paws and\n");
break;
}
else if((c != 'c' || c != 'C') && sleep == 0) //damage 40
{
printf("\nYou failed to catch it and as it turns around it hurts you with its tail.\n");
getch();
break;
}
}
printf("Jhon takes out his Swiss Army knife and stabs him in the throat, killing him.\n");
}