title: Read each line from a file and split the line into a string and an array in C
body: <p><strong>Homework</strong> - I have an assignment to write a program that will read a file. The file looks like this:</p>
  
  <pre><code>B 34 55 66 456 789 78 59 2 220 366 984 132 2000 65 744 566 377 905 5000
  I 9000
  I 389
  Dm
  DM
  </code></pre>
  
  <p>Where <code>B</code> is build a binary heap from an array of numbers(the numbers following the B.
  I is insert a number into the array/heap
  Dm is delete minimum and DM is delete maximum.</p>
  
  <p>I have written the code for the heap, and can fill an array with <code>random numbers</code>. My problem is reading that <code>first line</code> and parsing it into a <code>string B</code> and an <code>array</code>.</p>
  
  <p>I have tried using the following code but obviously it does not work.</p>
  
  <pre><code>char line[8];
  char com[1];
  int array[MAX] //MAX is pre-defined as 100
  
  FILE* fp = fopen( "input_1.txt", "r" );
  if( fp )
  {
      while( fgets ( line, sizeof(line), fp ) != NULL  )
      {
          sscanf(line, "%s" "%d", &amp;com, &amp;array );
          ... //Following this, I will have a nested if that will take
          each string and run the appropriate function.
  
          if ( strcmp( com, "B" ) == 0 )
          {
              fill_array( array, MAX );
              print_array( array, MAX );
          }        
  </code></pre>
  
  <p>I have read for about 6 hours over a total of 3 days and can't find a solution to my problem. Any help would be great.</p>