title: Reading in a text file in C, separate lines into multiple variables
body: <p>I'm currently working on a program that simulates various CPU scheduling methods.  Currently I have the program asking for input:</p>
  
  <pre><code>printf("Enter type of CPU scheduling algorithm (SJF, RR, PR_noPREMP, PR_withPREMP): ");
  scanf("%s", typeOf);
  
  printf("Enter number of processes: ");
  scanf("%d", &amp;numPro);
  
  struct processStruct structs[numPro];
  int burstTimes[numPro];
  
  for (i = 0; i &lt; numPro; i++) {
      printf("Enter process number: ");
      scanf("%d", &amp;structs[i].pNum);
      printf("Enter arrival time: ");
      scanf("%d", &amp;structs[i].arTime);        
      printf("Enter CPU burst time: ");
      scanf("%d", &amp;structs[i].cpuBur);        
      printf("Enter priority: ");
      scanf("%d", &amp;structs[i].prio);
  }
  </code></pre>
  
  <p>In addition to the two variables typeOf (an int) and numPro (a char array) I am also using a data structure.</p>
  
  <p>Here is the data structure that is holding the various parameters:</p>
  
  <pre><code>struct processStruct {
      int pNum;
      int arTime;
      int cpuBur;
      int prio;
      int waitTim;
  };
  </code></pre>
  
  <p>Instead of manual input I could like to use a text file with the same information as input for the program.  The text file would look something like this:</p>
  
  <pre><code>SJF
  4
  1 0 6 1
  2 0 8 1
  3 0 7 1
  4 0 3 1
  </code></pre>
  
  <p>First line is the name of the scheduling algorithm.
  Second line is the number of processes.
  The following lines consists of information for each process.  So 1 0 6 1 = Process = 1, 0 = Arrival Time, 6 = CPU burst time, 1 = Priority</p>
  
  <p>I unfortunately have little experience using text file input with C.  Does anyone have ideas about how I could read in the data from the text file into the variables and data structure?</p>
  
  <p>Thank you</p>
  
  <p>Edit: One of the issues I am having is that the data is not the same for each line. If it was just the rows of 4 numbers then it would be relatively easy. I need the program to read the first line into a char array (string), the second into the numPro variable then the subsequent lines into multiple instances of the data structure (one for each process).</p>