title: Read int and string with a delimeter from a file in C++
body: <p>I'm trying to read line by line in a file. Basically each line will have the Id number, price, qty and the name of the book. I know that after each input, I have to put the delimiter flag there to stop the reading, but I don't know how. I was trying to use <code>getline()</code>, yet, <code>getline()</code> can only take in a string, and that is not the case for the id #, the price and the qty. Would anyone care to show me the way how to read the file ? Thank you, and this is what I have so far.</p>
  
  <p>Example:
  The file should contain many line, each line will have a format like this:
  - The first number is the id number
  - The second one is the price
  - Third one is the qty
  - The last one is the title of the book</p>
  
  <p>123,19.99,5,summer is fun</p>
  
  <pre><code>void ReadFromFile(int ids[], int prices[], int qty[], string titles[], int&amp; count)
  {
      ifstream infile("tomatoes.txt");
      if(!infile.is_open())
          cout &lt;&lt; "File does not exists" &lt;&lt; endl;
      else
      {
          while(!infile.eof())
          {
              infile &gt;&gt; ids[count];
              infile &gt;&gt; prices[count];
              infile &gt;&gt; qty[count];
              getline(infile, titles[count]);
              if(!infile.eof())
                  count++;
          }
      }
  }
  </code></pre>