title: Pointers and loops in C
body: <p>Please know that I'm still very new to C and pointers in general... <strong>This is for a class so I'm not asking for explicit code</strong>, only help <em>understanding</em> the concepts.</p>
  
  <p>I'm trying to create a loop to assign random values to an int within a struct. The problem occurs when I'm assigning values to the current iteration of my pointer or array.</p>
  
  <pre><code>struct student{
      int id;
      int score;
  };
  
  struct student* allocate(){
      /*Allocate memory for ten students*/
      int ROSTER_SIZE = 10;
      struct student *roster = malloc(ROSTER_SIZE * sizeof(struct student));
  
      /*return the pointer*/
      return roster;
  }
  
  void generate(struct student* students){
      /*Generate random ID and scores for ten students, ID being between 1 and 10, scores between 0 and 100*/
      int i = 0;
  
      for (i = 0; i &lt; 10; ++i) {
          students[i]-&gt;id = i + 1;
          students[i]-&gt;score = rand()%101;
  }
  </code></pre>
  
  <p>Now, from my understanding, which is most likely incorrect, I should be able to use <code>students[i]</code> to assign values to each iteration, but VS 2010 tells me "the expression must have a pointer type." Isn't it already a pointer? It's passed into the function as a pointer, right?</p>