title: Using getline(cin, string)
body: <p>So I was reading about <code>getline(cin, string);</code> and tried to use it to give a string with multiple word.
  My simple code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main()
  {
      string test;
      getline(cin, test);
      cout &lt;&lt; test &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  
  <h1>This works perfectly</h1>
  
  <p>But if I use the same code in a little more complicated program, it just gets ignored!</p>
  
  <p>My just-started program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;limits&gt;
  #include &lt;string&gt;
  using namespace std;
  
  struct mainstruct
  {
  ofstream f_list;
  
  void write()
  {
      int rating;
      string name, watch, wprint;
      cout &lt;&lt; "Modifying" &lt;&lt; endl;
      f_list.open ("TextFile.txt", ios::app);
      cout &lt;&lt; "Name/Title?" &lt;&lt; endl;
      getline(cin, name);
      //cin.clear();
      //cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
      cout &lt;&lt; "Rating?" &lt;&lt; endl;
      cin &gt;&gt; rating;
      //cin.clear();
      //cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
      cout &lt;&lt; "Watched or unwatched?" &lt;&lt; endl;
      getline(cin, watch);
      //cin &gt;&gt; watch;
      if (watch == "w" || watch == "yes" || watch == "y")
      {
          watch = "W";
          wprint = "Watched";
      }
      else
      {
          watch = "DW";
          wprint = "Didn't watch";
      }
      cout &lt;&lt; name &lt;&lt; " (" &lt;&lt; rating &lt;&lt; "/10) (" &lt;&lt; wprint &lt;&lt; ") has been added to the list" &lt;&lt; endl;
      f_list &lt;&lt; name &lt;&lt; " " &lt;&lt; rating &lt;&lt; " " &lt;&lt; watch &lt;&lt; endl;
      //cin.clear();
      //cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
  }
  
  void read()
  {
      cout &lt;&lt; "Reading" &lt;&lt; endl;
      f_list.open("TextFile.txt");
  }
  
  void shutdown()
  {
      f_list.close();
  }
  };
  
  int main()
  {
  string answ, test;
  mainstruct o_list;
  do
  {
      cout &lt;&lt; "\n\nWould you like to check the list, modify or close it?" &lt;&lt; endl;
      cin &gt;&gt; answ;
      if (answ == "modify" || answ == "m" || answ == "write" || answ == "w")
      {
          o_list.write();
      }
      else if (answ == "check" || answ == "c" || answ == "read" || answ == "r")
      {
          o_list.read();
      }
      else if (answ != "modify" || answ != "m" || answ != "write" || answ != "w" || answ != "check" || answ != "c" || answ != "read" || answ != "r")
      {
          if (answ == "close" || answ == "quit" || answ == "q")
          {
              cout &lt;&lt; "File closed, list saved" &lt;&lt; endl;
          }
          else
          {
              cout &lt;&lt; "Invalid input" &lt;&lt; endl;
          }
      }
      o_list.shutdown();
  } while (answ != "close" &amp;&amp; answ != "quit" &amp;&amp; answ != "q");
  o_list.shutdown();
  
  getline(cin, test);
  cout &lt;&lt; test &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  
  <p>Here my getlines just get ignored!
  (I used <code>cin &gt;&gt; string;</code> before thats why those <code>cin.clear();</code>'s and <code>cin.ignore();</code>'s are there.</p>