how do i get this to work??
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cin >> name;
if (name == 'hi')
{
cout << "\nHELLO THERE!!";
}
else
{
cout << "\nYou didnt say hi!";
}
return 0;
}
Printable View
how do i get this to work??
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cin >> name;
if (name == 'hi')
{
cout << "\nHELLO THERE!!";
}
else
{
cout << "\nYou didnt say hi!";
}
return 0;
}
Replace 'hi' with "hi"
You used single quotes around the test string instead of double quotes.
Code:#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cin >> name;
if (name == "hi")
{
cout << "\nHELLO THERE!!";
}
else
{
cout << "\nYou didnt say hi!";
}
return 0;
}
Heh, that was a close one.