Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why wont my "intellect" variable add by 5?

Tags:

c++

if (checkForRoll == "intellect" && checkForRoll == "Intellect") {//checks for intellect
        intellect = intellect + 5;
    } else if (checkForRoll == "strength" && checkForRoll == "Strength") {
        strength = strength + 5;
    }
    cout << intellect;

When I execute this, the intellect int does not add by 5. Why?

like image 338
Matt Bettinson Avatar asked Feb 18 '11 00:02

Matt Bettinson


2 Answers

You are requiring your string to equal both intellect and Intellect which is impossible. Change the "and" (&&) to an "or" (||).

like image 65
GWW Avatar answered Sep 30 '22 17:09

GWW


Your variable checkForRoll can't be 'strength' && 'Strength', it can be 'strength' || 'Strength' however.

like image 23
Pudgeball Avatar answered Sep 30 '22 17:09

Pudgeball