title: C++ how to read a line with delimiter until the end of each line?
body: <p>Hi I need to read a file that looks like this...</p>
  
  <pre><code>1|Toy Story (1995)|Animation|Children's|Comedy
  2|Jumanji (1995)|Adventure|Children's|Fantasy
  3|Grumpier Old Men (1995)|Comedy|Romance
  4|Waiting to Exhale (1995)|Comedy|Drama
  5|Father of the Bride Part II (1995)|Comedy
  6|Heat (1995)|Action|Crime|Thriller
  7|Sabrina (1995)|Comedy|Romance
  8|Tom and Huck (1995)|Adventure|Children's
  9|Sudden Death (1995)|Action
  </code></pre>
  
  <p>As you can see the type of each movie can vary from 1 type to many...I wonder how could I read those until the end of each line?</p>
  
  <p>I'm currently doing:</p>
  
  <pre><code>void readingenre(string filename,int **g)
  {
  
      ifstream myfile(filename);
      cout &lt;&lt; "reading file "+filename &lt;&lt; endl;
      if(myfile.is_open())
      {
          string item;
          string name;
          string type;
          while(!myfile.eof())
          {
              getline(myfile,item,'|');
              //cout &lt;&lt;item&lt;&lt; "\t";
              getline(myfile,name,'|');
              while(getline(myfile,type,'|'))
              {
                  cout&lt;&lt;type&lt;&lt;endl;
              }
              getline(myfile,type,'\n');
          }
          myfile.close();
          cout &lt;&lt; "reading genre file finished" &lt;&lt;endl;
      }
  }
  </code></pre>
  
  <p>the result is not what I want...It looks like:</p>
  
  <pre><code>Animation
  Children's
  Comedy
  2
  Jumanji (1995)
  Adventure
  Children's
  Fantasy
  3
  Grumpier Old Men (1995)
  Comedy
  Romance
  </code></pre>
  
  <p>So it doesn't stop at the end of each line...How could I fix this?</p>