title: Trying to populate an array using a function in C++
body: <p>So, I'm trying to populate and print a small array using functions, however I've hit a bit of a roadblock. The code I have is: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct planes
  {
      string name;
      int seats;
      int range;
      int weight;
  };
  
  int populate (planes planesArray[5])
  {
      string name;
      int seats, range, weight, i;
      ifstream infile;
      infile.open("plane_data.txt");
      if (!infile)
      {
          cout &lt;&lt; "File cannot be reached";
      }
  
      for (int i = 0; i &lt; 4; i++){
          infile &gt;&gt; name;
          infile &gt;&gt; seats;
          infile &gt;&gt; range;
          infile &gt;&gt; weight;
  
      }
  
      infile.close();
  
  }
  
  
  
  int main() {
  
      planes planesArray[5];
      populate(planes planesArray[5]);
  
  };
  </code></pre>
  
  <p>I'm getting a multitude of errors in the different iterations of code I'm using. With this one pasted above I am getting:</p>
  
  <pre><code>line 44: error: expected primary expression before (planesArray)
  </code></pre>
  
  <p>I'm a bit lost to be honest. There are 5 pieces of data in the array, I just don't know how to get the data from the file into the array reliably using the functions I've created. </p>
  
  <p>Any help would be much appreciated!</p>