How would you insert a string name that isn't a number into an "if" statement in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How would you insert a string name that isn't a number into an "if" statement in C++?

If you have string name; and cin >> name;, how would you put it into an if statement? string name; cin >> name; if (name = test){ cout << name << endl ; }

26th Apr 2018, 10:01 PM
JDLives
2 Answers
26th Apr 2018, 11:08 PM
Emma
+ 1
#include <iostream> using namespace std; int main() { string name; cin>>name; if (name == "TheGreatSaga") { cout<<"string matched"<<endl; } return 0; }
27th Apr 2018, 3:10 PM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar