title: c++ missing data while reading from file
body: <p>Hi guys sry to trouble you. I have 2 problems.</p>
  
  <ol>
  <li>I having problem printing out the last data in my file </li>
  <li>How can i print out only certain row start with the username</li>
  </ol>
  
  <p>Data:</p>
  
  <pre><code>tom12:Miscellaneous:-30.52:20JAN15
  ben23:Utility Bill:-56.50:17JAN15
  tom12:Child Needs:-80.95:15JAN15
  tom12:Baby needs:-20.9:18JAN15
  ben23:Phone Bill:-35.90:12JAN14
  ben23:Housing Bill:-192.88:01JAN15
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>string line;
  ifstream file("expenses.txt");
  double totalNegative = 0;
  double totalPositive = 0;
  while(getline(file, line))
  {
      stringstream linestream(line);
      string data1;
      string data2;
      double data3;
      string data4;
      getline(linestream, data1, ':');
      getline(linestream, data2, ':');              
      linestream &gt;&gt;data3;
      getline(linestream, data4, ':');
      cout &lt;&lt; data2 &lt;&lt; " $" &lt;&lt; data3 &lt;&lt; " " &lt;&lt; data4 &lt;&lt; " "&lt;&lt; endl;
  }
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>Miscellaneous $-30.52
  Utility Bill $-56.50
  Child Needs $-80.95
  Baby needs $-20.9
  Phone Bill $-35.90
  Housing Bill $-192.88
  </code></pre>
  
  <p>The results are missing the dates at the last column. And how do i print out only "tom12" which is the user. Thanks!</p>