title: How to pass a file into a function?
body: <p>i am having difficulty understanding how to pass a file into a function. </p>
  
  <p>i have a file with 20 names and 20 test scores that needs to be read by a function. the function will then assign the names and scores to a structure called student.</p>
  
  <p>my question is how would i write a function call with the appropriate parameters. ? to make my function read the data in the file. thanks.</p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>// ask user for student file
  cout &lt;&lt; "Enter the name of the file for the student data to be read for input" &lt;&lt; endl;
  cout &lt;&lt; " (Note: The file and path cannot contain spaces)" &lt;&lt; endl;
  cout &lt;&lt; endl;
  cin &gt;&gt; inFileName;
  inFile.open(inFileName);
  cout &lt;&lt; endl;
  
  // FUNCTION CALL how do i set this up properly?
  ReadStudentData(inFile, student, numStudents ); 
  
  void ReadStudentData(ifstream&amp; infile, StudentType student[], int&amp; numStudents)
  {
      int index = 0;
      string lastName, firstName;
      int testScore;
  
      while ((index &lt; numStudents) &amp;&amp;
             (infile &gt;&gt; lastName &gt;&gt; firstName &gt;&gt; testScore))
      {
          if (testScore &gt;= 0 &amp;&amp; testScore &lt;= 100)
          {
              student[index].studentName = lastName + ", " + firstName;
              student[index].testScore = testScore;
              index++;
          }
      }
  
      numStudents = index;
  }
  </code></pre>