Quote:
Originally Posted by
Hatakescreams 
This is very much the idea I first tried problem comes when I try to scan for user input. If its bit one of yea or no the programngeta stuck in a loop. Also am on my phone so sorry for any mistakes I haven't noticed
I don't understand this part of your message
Quote:
If its bit one of yea or no the programngeta stuck in a loop
Anyways, since you've tried it that means you should be able to shove it all into a procedure to test this (Since I am unsure of the full structure of the program I can only assume bits)
I'll post some mock code you should be able to just insert easily later but for now my question is. Have you verified the input? ie. ensure it's catching just 0 or 1 or neither properly?
EDIT - here is some real code vs the mess I had earlier
Code:
void zombieGame(){
... // your game here
}
int playAgainChecker(){ //alternative is use bool
int checkVal = -1;
while(1){ // if using bool use true here
prinf("Would you like to play again? (Hit '1' for yes and '2' for no): ");
scanf("%i", &checkVal); //maybe it was %d
flushall();
printf("\n");
checkVal--;
if(checkVal < 0 || checkVal > 1){
printf("Sorry that was an invalid input\n");
// .. continue loop since invalid and should never leave until yes or no
}else{
return !checkVal; // since checkVal-- before causes 1 to be no and 0 to be yes
}
}
}
int main(int argc, const char* argv[]){ // Hmmm... or is it void
int cPlay = 1;
while(cPlay)
zombieGame(); // zombie game is independant of the main function
// once the zombie game is completed then check to play again
cPlay = playAgainChecker();
}
return 0;
}
Obviously, yours doesn't have to look like that to work, it's just a bad habit of mine lately. BTW typed up on notepad++ but I don't think there are that many mistakes.
I think one mistake in mine is if they type a character or anything not a number it'll ignore it... just a feeling I have.
Edited by JQuantum - 11/8/12 at 8:55am