I have to read in a file with inconsistent inputs. I am working on a Max-Heap and have all of the heap functions working properly. The file looks like:
5
1
2
3
4
5
I 7
E
C 3 9
E
D 2
The first number is the size of the heap. Then the remaining numbers are nodes in the heap. After this the remaining lines are operations. When the letter is "I" it will always only have one number following because it is to insert a value into the heap. When the letter is "E" it will only be to delete the root node (no following numbers). When the letter is "C" it will always have 2 numbers following because it is to change a nodes index. Lastly when the letter is "D" there will only be 1 number following and it is to delete the node at that index. Currently my code is:
while(!feof(fPtr)){
    char temp;
    int i, v, test=0;
    fscanf(fPtr, "%c", &temp);
    if(strcmp(&temp, "I")==0){
      test=1;
    }
    else if(strcmp(&temp, "C")==0){
      test=2;
    }
    else if(strcmp(&temp, "D")==0){
      test=3;
    }
    else{
      test=4;
    }
    switch(test){
      case 1:
        //if the character is I then read in the key
        fscanf(fPtr, " %d\n", &v);
        //insert new key v
        heapSize = insert(myHeap, heapSize, v);
        buildMaxHeap(myHeap, heapSize);
        break;
      case 2:
        //if the character is C then read in the index and key
        fscanf(fPtr, " %d %d\n", &i, &v);
        //change the key of the heap at index i to a new key
        heapChangeKey(myHeap, heapSize, i-1, v);
        buildMaxHeap(myHeap, heapSize);
        break;
      case 3:
        //if the character is D then read in the index
        fscanf(fPtr, " %d\n", &i);
        //delete key at index i in the heap
        heapSize = delete(myHeap, heapSize, i-1);
        buildMaxHeap(myHeap, heapSize);
        break;
      case 4:
        fscanf(fPtr, "\n");
        heapSize = delete(myHeap, heapSize, 0);
        buildMaxHeap(myHeap, heapSize);
        break;
    }
  }
Why does this code not read in the letters correctly?
