title: Trying to print the contents of an array in C++
body: <p>I'm using a function to populate an array from a text file. As far as I can tell, the array is populating fine, but when I come to print the array using cout I get a lot of errors which say that the data from the file could not be converted to different data types (if these errors are required, comment to let me know). </p>
  
  <p>The code I have so far is: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct plane //strcutre of plane data to use
  {
  string name;
  string direction;
  int id;
  int coordX;
  int coordY;
  int height;
  int speed;
  
  };
  
  int populate (plane planeArray[5])
  {
  string name, direction;
  int id, coordX, coordY, height, speed, i;
  ifstream infile;                              //declare input file stream
  infile.open("plane_data.txt");                //opens file
  if (!infile)
  {
      cout &lt;&lt; "File cannot be reached";         //checks for invalid file path
  }
  
  for (int i = 0; i &lt; 4; i++){
      infile &gt;&gt; planeArray.name[i];
      infile &gt;&gt; planeArray.direction[i];
      infile &gt;&gt; planeArray.id[i];
      infile &gt;&gt; planeArray.coordX[i];
      infile &gt;&gt; planeArray.coordY[i];
      infile &gt;&gt; planeArray.height[i];
      infile &gt;&gt; planeArray.speed[i];
  
  }
  
  infile.close();
  
  }
  
  void text_display(plane planeArray[5])
  {
  for (int i = 0; i &lt; 4; i++)
  {
      cout &lt;&lt; planeArray[i].name &lt;&lt; endl;
      cout &lt;&lt; planeArray[i].id &lt;&lt; endl;
      cout &lt;&lt; planeArray[i].coordX &lt;&lt; endl;
      cout &lt;&lt; planeArray[i].coordY &lt;&lt; endl;
      cout &lt;&lt; planeArray[i].height &lt;&lt; endl;
      cout &lt;&lt; planeArray[i].speed &lt;&lt; endl;
  }
  }
  
  
  int main() {
  
  plane planeArray[5];
  populate( planeArray);
  //text_display( planesArray);
  
  };
  </code></pre>
  
  <p>Any input is appreciated! </p>
  
  <p>Cheers </p>