How do I set two value to a string code below | Sololearn: Learn to code for FREE!
0

How do I set two value to a string code below

string yes_vary; yes_vary = "Yes","sure"; if(a==yes_vary) { cout << " it works" << endl; }

31st Jan 2019, 4:16 AM
Nicholas Marcello
Nicholas Marcello - avatar
2 Answers
+ 4
You can't store two strings in one string variable, but you can check more than 1 condition in one if statement. if (a == "Yes" || a == "sure") { // It works }
31st Jan 2019, 4:52 AM
Hatsy Rei
Hatsy Rei - avatar
0
I want to be able to enter yes or sure and the program output the same thing but the problem is this. yes_vary = "Yes","sure"; I want it to be string yes_vary; yes_vary = "Yes" or "sure";
31st Jan 2019, 4:18 AM
Nicholas Marcello
Nicholas Marcello - avatar