title: C compile error: expected declaration or statement at end of input
body: <p>When I try to compile my code I get three errors all stating
  "error: expected declaration or statement at end of input"
  All pointing to the same line. The line changes depending on sections that I have commented out. The least amount of code I can leave still in the function while still getting the error is the declaration lines at the top of the function.</p>
  
  <p>All other solutions point to there not being a closed bracket somewhere, but I have searched and cannot find one. </p>
  
  <p>Any help would be appreciated. </p>
  
  <pre><code>void get_agents(struct Base* s) {
  int count;
  char c = 'A'; //temp char declartion
  char temp1, temp2;
  char *file, *extra, *line;
  
  line = malloc(sizeof(char)*128); 
  file = malloc(sizeof(char)*256); 
  extra = malloc(sizeof(char)*256); 
  
  s-&gt;agentfile = fopen(s-&gt;agentfilename, "r");
  while (c != EOF) {
      fgets(line,500,s-&gt;agentfile);
      c = line[0]; //gets first char from line
      if (c != '#') {
          struct Agent* newAge = malloc(sizeof(struct Agent));
          struct Agent* agentNum = malloc(sizeof(struct Agent));
  
          newAge-&gt;next = 0; 
          sscanf(line, "%d %d %c %s%c%s%c", &amp;newAge-&gt;posx, &amp;newAge-&gt;posy,
          &amp;newAge-&gt;name, file, &amp;temp1, extra, &amp;temp2);
  
          agentNum = s-&gt;start //sets agentNum to the first agent in list
          if (agentNum == NULL) { //does first agent exist?
              s-&gt;start = newAge; //first agent in list
          } else {
              while (agentNum-&gt;next) { //is this not the last agent?
                  agentNum = agentNum-&gt;next; //get the next agent
              }
              agentNum-&gt;next = newAge; //else, set newagent to be new last
          }
      }
  }
  }
  </code></pre>