title: How do I read a text file into an array of pointers? (C++)
body: <p>What I need to do is read a text file into an array. Each line has four parts; first name, the ID, the height, and the weight. There are 13 lines in the text file, so I need to do it 13 times. I'm going to write a loop to make it work (and will be in a function I will parse the array to.) I know how to do it with a basic array, but we're supposed to use structs for this. I've looked around to try to find out how to do this, but nothing's really working for me. Here's the code I have so far.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  using namespace std;
  struct person
  {
  string firstname;
  int id;
  double height;
  double weight;
  };
  int main()
  {
  person array[13];
  person *ptr;
  ptr = &amp;array[0];
  ifstream inData;
  inData.open("peeps.txt");
  while(!inData.eof())
  {
      for(ptr = &amp;array[0]; ptr &lt; &amp;array[13];ptr++)
      {
          inData &gt;&gt; person[ptr].firstname &gt;&gt; person[ptr].id
          &gt;&gt; person[ptr].height &gt;&gt; person[ptr].weight;
  
  
      }
  }
  }
  </code></pre>