title: Putting numeric data from an input file into a linked list
body: <p>I am writing a function that will <strong>read</strong> an input file and <strong>write</strong> the numbers into a linked list. There are two rows of numbers in the input file, an integer and a double:</p>
  
  <p><strong>Int</strong>
  1
  1
  1
  <strong>Float</strong>
  1.2
  1.4
  2.4</p>
  
  <p>except theyre in vertical rows. Think of it as a T chart, with 1 column being integer numbers and 1 column being floats. Each <strong>row</strong> of the column has 1 int and 1 float, so they are <strong>grouped</strong> together. I want to store <strong>each</strong> group of the table in a node of a linked list.
  The question is, how do I read them into a linked list? Let's say I have created one of Class FlowList. FlowList has a <strong>next</strong> pointer, and a <strong>node</strong> which contains an integer and float storage.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>
  struct ListItem{
      int year;
      double flow;
  };
  
  struct Node{
      ListItem item;
      Node *next;
  };
  
  class FlowList{
  
      Node *headM;
  
  
  </code></pre>
  
  <p>So basically, if the numbers line up in the row/ are in the same group, (ie, 1 and 2.22 line up with each other) then they go into the same Node.</p>
  
  <pre><code>**year**                **flow**
      1                       1.5
      2                       3.3  &lt;--------this row goes into one node of the 
                                            linked list
  
  
  
  
  </code></pre>
  
  <p>Here's a sample of what I wrote so far (it isn't much at all):</p>
  
  <p>Also, the input file is guaranteed to have only numbers in it, so there is no worry about that.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int readData(FlowList&amp; x){
  
      int c=0; //counter which reads the number of nodes created.
      ifstream fpr;
      fpr.open("flow.txt");
      if(!fpr){
          cerr&lt;&lt;"Error in opening file";
          exit(1);
      }
  //and then I have no idea what to do beyond here.
  
  </code></pre>
  
  <p>Now I'll create a new FlowList called x. The way to access the integer and float is by using the syntax below:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>x.head-&gt;item.year
  x.head-&gt;item.flow
  </code></pre>
  
  <p>Im still very new to c++, so let me know if i need to clarify anything.
  Thanks</p>