I saw a similar question to mine: C++ string variables with if statements
The only difference between his situation and mine is that I would like the condition to be if a string with a space is matching a certain string.
Here is my code:
#include <iostream>
#include <string>
int main()
{
using namespace std;
string input1;
cout << "Welcome to AgentOS V230.20043." << endl;
cout << "To log in, please type \"log in\"" << endl;
cin >> input1;
if (input1 == "log in")
{
cout << "Please enter your Agent ID." << endl;
}
return 0;
}
For some reason, the if statement is not picking up the string. However, if the conditions is:
if (input1 == "login"
It works. I cannot find a way to use a string with a space in it with a condition. I am wondering if maybe the if statement is okay but that the cin is deleting the space.
Thank you!