Issues with ifstream reading CSV data : <p>Non-working code:</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;fstream&gt;
#include&lt;string&gt;
int main(){
int id; string name;char comma ; double money;
ifstream read("testfile.csv");
 while (read &gt;&gt; id &gt;&gt; comma&gt;&gt; name &gt;&gt; comma &gt;&gt; money)
 {cout &lt;&lt; id &lt;&lt;comma&lt;&lt;name&lt;&lt;comma&lt;&lt;money&lt;&lt;  endl ;}
 read.close();
 _getch();
return 0;}
</code></pre>

<p>The csv file data &amp; structure:</p>

<p><code>1,user1,999
 2,user2,33
 3,user3,337</code></p>

<p>But, the following works fine. Why so?</p>

<p><code>while (read &gt;&gt; id &gt;&gt;comma&gt;&gt;name)
     {cout &lt;&lt; id&lt;&lt;comma&lt;&lt;name &lt;&lt;endl ;}</code></p>
