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 ; }
3 Answers
+ 1
#include <iostream>
using namespace std;
int main() {
string name;
cin>>name;
if (name == "TheGreatSaga")
{
cout<<"string matched"<<endl;
}
return 0;
}