I'm writing the classic "Guess my number" program.
I don't seem to understand why the while loop doesn't stop working even after I wrote "Success" and goes to the default route.
int xRan;
void rdm(int to, int from){
srand(time(NULL));
xRan = rand()%to+from;
}
void iGuess(){
string b;
int tries = 1;
cout << "Think of a number between 1 and 100" << endl;
rdm(100, 1);
while(b != "Success" || b != "success"){
cout << "is your number higher or lower than " << xRan << ". (attempt #" << tries << ")" << endl;
cout << "If I guessed your number, please type 'Success' " << endl;
cout << "-->";
cin >> b;
if(b == "Lower" || b == "lower"){
rdm(xRan, 1);
tries++;
}else if(b == "Higher" || b == "higher"){
rdm(100, xRan);
tries++;
}else{
cout << "This is not a valid choice." << endl;
}
}
cout << "I'm so good! I did it in " << tries << "attempts!" << endl;
}