get a line until | in iostream : <p>Currently I'm using the code below to read some variable from a text file like this:</p>

<blockquote>
  <p>12345|54321|TAN Ah Kow  |M|12 Jalan 3/45 KL  |Wilayah P|012-3456789|5000.00</p>
</blockquote>

<p>The code is</p>

<pre><code>getline(infile,id,'|');
getline(infile,pw,'|');
getline(infile,name,'|');
getline(infile,gender,'|');
getline(infile,address,'|');
getline(infile,state,'|');
getline(infile,phone,'|');
getline(infile,balance,'|');
</code></pre>

<p>is there any better way to do this?</p>
