&& with strings
So using "&&" gives me an error no operator "&&" matches these operands. Can you not compare strings?
Help please?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
#include <string>
using namespace std;
int main(){
string playerInput = "";
string compInput = "c";
if (playerInput = "c" && compInput = "c")
{
cout << "You chose to cooperate"
<< "The computer chose to cooperate"
<< "You get 1 penalty point";
}
}
|
- Extreme112
Use == to test for equality, not = as that is assignment.
OHHHH. Such a stupid mistake. Thanks
Topic archived. No new replies allowed.