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 Antworten
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