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;
}
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"
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
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; }
Processing error: Stupidity detected.
------------------------------
Dr. Bebop
Windows XP Professional Ed.
Microsoft Visual Studio 6
Heh, that was a close one.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling