Hi all
i am trying to use a switch statement to ask if a player wants to play again
however when the user hits anything but 1 or 0, cmd goes into a loop of the whole quiz, repasting everything over and over thus the title (zombie program) was wondering if anyone can see something obvious?
I realize that default is meant to be run in the event 1 or 0 have not been pressed, i even tried putting the switch inside a "while(x == 1)" and when the default is run "x = 1;" until one other cases changed it back to " x = 0; "
thanks much Dom
i am trying to use a switch statement to ask if a player wants to play again
Code:
//play again
printf("would you like to play again?: 1\\0\n");
scanf("%d", &pagain);
switch(pagain){
case 1:
play = 1;
printf("success!\n");
break;
case 0:
printf("Goodbye!\n");
exit(0);
break;
default:
printf("please enter a valid key\n");
}
however when the user hits anything but 1 or 0, cmd goes into a loop of the whole quiz, repasting everything over and over thus the title (zombie program) was wondering if anyone can see something obvious?
I realize that default is meant to be run in the event 1 or 0 have not been pressed, i even tried putting the switch inside a "while(x == 1)" and when the default is run "x = 1;" until one other cases changed it back to " x = 0; "
thanks much Dom








