title: C++ Structure Pointer to Object type error
body: <p>I am having an issue with C++ structures. In my program below, I am trying to read from a file the number of questions to an exam, the answers to the exam, and the file of the student's answers to the exam. That all works, but when I try to put the student's info into an array for a structure, the variable id doesn't work for some reason. The compiler, which is Microsoft Visual Studio 2017 RC, says that "students->id[i]" has an error which says: "expression must have pointer to object type" and I don't know why. I marked where the issue is and took off the rest of the code, all I have is the function calculateGrade being used. I've worked on this for a while now and can't get anywhere without fixing this. Any help is appreciated!</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;string&gt;
  using namespace std;
  struct studentInfo {
      int id;
      string firstName;
      string lastName;
      string exam;
  };
  double calculateGrade(struct studentInfo);
  int main() {
      const int SIZE = 12;
      studentInfo students[SIZE];
      string fileName, key, studentFile;
      ifstream file, fileForStudents;
      int numOfQuestions, i = 0, id;
  
      cout &lt;&lt; "Please enter a file name: ";
      cin &gt;&gt; fileName;
  
      file.open(fileName);
      if (!file.is_open()) {
          cout &lt;&lt; "Could not open file";
      }
  
      file &gt;&gt; numOfQuestions &gt;&gt; key &gt;&gt; studentFile;
  
      fileForStudents.open(studentFile);
      if (!fileForStudents.is_open()) {
          cout &lt;&lt; "Could not open file";
      }
  
      while (!fileForStudents.eof()) {
  
          fileForStudents &gt;&gt; id &gt;&gt; students-&gt;firstName[i] &gt;&gt; students-&gt;lastName[i] &gt;&gt; students-&gt;exam[i];
  
          students-&gt;id[i] = id; //issue is here
  
          i++;
      }
  
      calculateGrade(students[SIZE]);
  
  
      return 0;
  }
  </code></pre>