title: reading text with whitespaces in c++
body: <p>i'm trying to read in the following text file into different variables:</p>
  
  <pre><code>title
  subject name
  123
  subject2 name
  124
  subject3 name
  125
  </code></pre>
  
  <p>so far i've been using the following code</p>
  
  <pre><code>ifstream myfile;
  myfile.open("filename.txt");
  ......etc
  
  myfile &gt;&gt; string1
  while(myfile &gt;&gt; string2 &amp;&amp; myfile &gt;&gt; int1){
      cout &lt;&lt; "read string " &lt;&lt; string2 &lt;&lt; "and int " &lt;&lt; int1 &lt;&lt; endl;
  }
  </code></pre>
  
  <p>This method doesn't seem to like the space between "subject name" and it isn't picking up so it doesn't run the while loop. Is there an easy way i can fix this?</p>