sum1nowhere
Baseband Member
- Messages
- 85
How do I set a variable equal to a word? Like as in a user name? So that it only accepts one user name? I have tried doing "
cout << "Name:" << endl;
string user;
cin >> user;
if (user == Bob)
{
cout << "Welcome" << endl;
}
else
{
cout << "The name you entered is not a valid." << endl;
}
"
I know that is not how it is supposed to be done, but I am just a newbie teaching myself what I can before college starts in January. So can any one tell me how to make it so it only accepts certain inputs?
cout << "Name:" << endl;
string user;
cin >> user;
if (user == Bob)
{
cout << "Welcome" << endl;
}
else
{
cout << "The name you entered is not a valid." << endl;
}
"
I know that is not how it is supposed to be done, but I am just a newbie teaching myself what I can before college starts in January. So can any one tell me how to make it so it only accepts certain inputs?