title: Read access violation, error code 0xFFFFFFFFFFFFFFFF
body: <p>I'm sorry this is a repeat question, but no solutions seem to work for my code.</p>
  
  <p>This is for an assignment in school on reading from a file and copying the data to an array. An exception is thrown every time I try to edit the array "arr" in main.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  struct Student {
      string name;
      float gpa;
      int id;
  };
  
  void PrintStudents(Student arr[], int nstudents) {
      for (int i = 0; i &lt; nstudents; i++) {
          cout &lt;&lt; "Student name: " &lt;&lt; arr[i].name &lt;&lt; endl;
          cout &lt;&lt; "Student GPA: " &lt;&lt; arr[i].gpa &lt;&lt; endl;
          cout &lt;&lt; "Student ID: " &lt;&lt; arr[i].id &lt;&lt; endl;
      }
  }
  
  int ReadStudents(string fname, Student arr[]) {
      ifstream file;
      file.open(fname);
  
      int counter = 0;
      string name_local;
      float gpa_local;
      int id_local;
  
      int index = 0;
  
      while (!file.eof()) {
          if (counter == 0) {
              file &gt;&gt; name_local;
          }
          else if (counter == 1) {
              file &gt;&gt; gpa_local;
          }
          else if (counter == 2) {
              file &gt;&gt; id_local;
          }
  
          counter++;
  
          if (counter == 3) {
              counter = 0;
              Student newStudent = { name_local, gpa_local, id_local };
              arr[index] = newStudent;
              index++;
          }
      }
  
      file.close();
      return index;
  }
  
  void fillStudentArray(Student array[], int array_size) {
      Student temp = { "", 0, 0 };
      for (int i = 0; i &lt; array_size; i++) {
          array[i] = temp;
      }
      return;
  }
  
  int main() {
      Student arr[128];
      fillStudentArray(arr, 128); // exception thrown here??
      cout &lt;&lt; "Array filled." &lt;&lt; endl;
  
      cout &lt;&lt; "Reading students" &lt;&lt; endl;
      int nstudents = ReadStudents("csci10.hw8.students.txt", arr);
      PrintStudents(arr, nstudents);
  
      return 0;
  }
  </code></pre>
  
  <p>Thanks for any help! I'm totally stumped.</p>
  
  <p>Edit: Woah, I left for a 30 minute coffee break and came back to a ton of answers! I'll try to respond to all of them.</p>
  
  <p>Edit 2: Just got a solution! I was working in VS 2019, switched to old school terminal G++ and it worked! Thanks everyone for all the answers :)</p>