Why isn't this string if statement working?

I could've sworn iv'e done this a million times

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
int main()
{
	std::cin >> reaction;

	if (reaction == "look at")
	{
		std::cout << "shackles\n";
		std::cout << "jail uniform\n";
		std::cout << "bench\n";
		std::cout << "cell door\n";
		std::cout << "jail bars\n";
		std::cout << "jail guard\n";
	}
}
Where is reaction declared?
sorry

#include <iostream>
#include <string>
int main()
{
std::string reaction = "none";

std::cin >> reaction;

if (reaction == "look at")
{
std::cout << "shackles\n";
std::cout << "jail uniform\n";
std::cout << "bench\n";
std::cout << "cell door\n";
std::cout << "jail bars\n";
std::cout << "jail guard\n";
}
}
The >> operator only reads one word. If you want to read the whole line you could use std::getline.

http://www.cplusplus.com/reference/string/string/getline/
That didnt work
Just kidding
Topic archived. No new replies allowed.