bool playAgain()
{
char yesOrNo;
cout << "Do you want to play again (y/n)? ";
cin >> yesOrNo;
if (yesOrNo == 'y')
returntrue;
elseif (yesOrNo == 'n')
returnfalse;
elsewhile (yesOrNo != 'y' || yesOrNo != 'n')
{
cout << "Must enter y for yes, or n for no." << endl;
cout << "Do you want to play again (y/n)";
cin >> yesOrNo;
}
}
int main()
{
char madLibStory[256][32];
readFile(madLibStory);
do
{
readFile(madLibStory);
} while (playAgain());
return 0;
}
However, I'm having issues with this code. Certain variations will loop infinitely getting caught up each time at the first prompt (I didn't include the entire. Others will prompt to play again in the very beginning. This particular version runs it as I think it should run, but it will never prompt the user if they want to play again; which I think I understand why (the function isn't being called?)
What I need it to do is run the entire function and then prompt to play again. Can I get some direction on this? I've tried just about everything I can think of.
*PS: I apologize if someone saw a similar post a few days ago, I changed my program considerably [although I suppose this particular part isn't much different].
while(yesOrNo != 'y' || yesOrNo != 'n')
{
cout << "Must enter y for yes, or n for no." << endl;
cout << "Do you want to play again (y/n)";
cin >> yesOrNo;
//Check the new input..
if (yesOrNo == 'y')
returntrue;
elseif (yesOrNo == 'n')
returnfalse;
}