title: Storing certain information from a file to a data structure
body: <p>I am currently learning about to how to data structures in C and I need a little help. I am supposed to take information about classes from a .txt file and store the information in a data structure; but I am having trouble doing so. I am also sure that I am also screwing up a lot of other things in my program, so feel free to bash on my program and tell me what I am doing wrong so I can learn from my mistakes.</p>
  
  <p>Here is one line of information that I am trying to store:</p>
  
  <pre class="lang-none prettyprint-override"><code>M273 Multivariable Calculus :MWF 0900-0950 2
  </code></pre>
  
  <p>where the first part is the course number, the second part is the course name, the third part is the days and time the course is available and the last number represents what year you should be in to take the course (2 translates to sophomore).</p>
  
  <p>Below is my code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  
  #define EMAX 250
  
  typedef struct class{
      char *classNumber[EMAX];
      char *className[EMAX];
      char *classTime[EMAX];
      char *classStanding[EMAX];
  }class;
  
  void menu(class*info, char buffer[], FILE*file);
  void setInformation(class*info, char buffer[], FILE*file);
  
  int main(void)
  {
      class info[EMAX];
      char buffer[EMAX];
      File *file;
  
      setInformation(info, buffer, file);
      menu(info, buffer, file);
  
  return(0);
  }
  
  void menu(class*info, char buffer[], FILE*file)
  {
      int user_input=0;
  
      do {
      printf("\nSelect one of the following options: \n");
      printf("1) Print all information about all classes in order of the class number\n");
      printf("5) Quit\n");
      scanf("%d", &amp;user_input);
  
      if(user_input==1)
      {
          //getInformation(info, buffer, file);
      }
      }while(user_input!=5);
  }
  
  void setInformation(class*info, char buffer[], FILE*file)
  {
      size_t count = 0;
      char line[50];
      char *token;
  
      file = fopen("classes.txt", "r");
      while(fgets(line, sizeof(line), file)!=NULL)
      {
          token=strtok(line, " "); //Only gets the course number
          strncpy(info[count].classNumber, token, strlen(token));
          count++;
      }
      fclose(file);
  }
  </code></pre>
  
  <p>As you can tell, I can only extract the course number with this code. I would prefer to store all the data in one while loop and I have tried to extract more information by adding another token to stop as soon as it reaches the ":" before the day and time but I can't figure out how to get it to work. I also get a lot of warnings when I compile this, so I welcome any advice to help my trash code. I appreciate any help</p>