C++ question
PostPosted: Mon Jan 23, 2006 11:28 pm
Alright, I feel really stupid since I can't figure this out.
Ok, I have this loop that I want to terminate when the user presses any key but Y or y. Therefore, I have a boolean that evaluates as true only if the user presses Y or y. This bool determines whether or not the user stays in the do-while loop. Here's the code just for clarity...
or something like that. Anyways, for whatever reason, the bool doagain always evaluates to true, and the user can't exit the loop, no matter what he types. Obviously I'm doing something wrong here...
THis was so much easier in Java when we had equalsIgnoreCase...
Ok, I have this loop that I want to terminate when the user presses any key but Y or y. Therefore, I have a boolean that evaluates as true only if the user presses Y or y. This bool determines whether or not the user stays in the do-while loop. Here's the code just for clarity...
- Code: Select all
#include <iostream>
using namespace std
int main
{
*blah blah intro blah*
bool doagain = false;
char checking;
do
{
*code and stuff*
cin << checking;
if ((checking == 'y') || (checking == 'Y'))
doagain = true;
else
doagain = false;
}while (doagain = true);
return 0;
}
or something like that. Anyways, for whatever reason, the bool doagain always evaluates to true, and the user can't exit the loop, no matter what he types. Obviously I'm doing something wrong here...
THis was so much easier in Java when we had equalsIgnoreCase...