title: Problems using cin in C++
body: <p>So, I've just begun learning c++, and i've been watching some tutorials, etc. I wrote a small program that should act like a magic eight ball, however I'm having some troubles with the cin command. I've written cin >> x; where x is a string, and when the user types their question, the program is supposed to print a random response. Sounds simple enough, but if the user types more than 1 word in the question, more than 1 response is printed. So, if i type "Will I live to be 100?" I get 6 answers instead of 1. Here's my code: (I'm sure it's probably messy and not very well organized or coded in the most efficient way, like I said, I'm a beginner.)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  string z = "Yes";
  string b = "Signs point to yes";
  string c = "It is certain";
  string d = "It is decidedly so";
  string e = "Without a doubt";
  string f = "Yes, definitely";
  string g = "You may rely on it";
  string h = "As I see it yes";
  string i = "Most likely";
  string j = "Outlook good";
  string k = "Reply hazy try again";
  string l = "Ask again later";
  string m = "Better not tell you now";
  string n = "Cannot predict now";
  string o = "Concentrate and ask again";
  string p = "Don't count on it";
  string q = "My reply is no";
  string r = "My sources say no";
  string s = "Outlook not so good";
  string t = "Very doubtful";
  string u;
  
  int main()
  {
      srand(time(0));
  
      cout &lt;&lt; "Ask A Question" &lt;&lt; endl &lt;&lt; endl &lt;&lt; "Type 'Exit' to end the program" &lt;&lt; endl &lt;&lt;           endl;
      int a = 1+(rand()% 20);
      cin &gt;&gt; u;
  
  if (u == "Exit"){
      return 0;
  }
  if (u == "exit"){
      return 0;
  }
  
  
  
  if (a == 1){
      cout &lt;&lt; z &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 2){
      cout &lt;&lt; b &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 3){
      cout &lt;&lt; c &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 4){
      cout &lt;&lt; d &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 5){
      cout &lt;&lt; e &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 6){
      cout &lt;&lt; f &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 7){
      cout &lt;&lt; g &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 8){
      cout &lt;&lt; h &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 9){
      cout &lt;&lt; i &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 10){
      cout &lt;&lt; j &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 11){
      cout &lt;&lt; k &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 12){
      cout &lt;&lt; l &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 13){
      cout &lt;&lt; m &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 14){
      cout &lt;&lt; n &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 15){
      cout &lt;&lt; o &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 16){
      cout &lt;&lt; p &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 17){
      cout &lt;&lt; q &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 18){
      cout &lt;&lt; r &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 19){
      cout &lt;&lt; s &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  if (a == 20){
      cout &lt;&lt; t &lt;&lt; endl &lt;&lt; endl;
      main();
  }
  
  
      return 0;
  }
  </code></pre>