Hello guys, I am trying to create a multiple choice adventure in C. The player can only choose option A or B. The files I read look like this one:
> Kapitel 1
'Would you tell me, please, which way I ought to go from here?'
'That depends a good deal on where you want to get to,' said the Cat.
'I don't much care where -' said Alice.
'Then it doesn't matter which way you go,' said the Cat.
'- so long as I get SOMEWHERE,' Alice added as an explanation.
'Oh, you're sure to do that,' said the Cat, 'if you only walk long enough.'

I have to create a binary tree and my current code looks like this:

#include <stdio.h>
    #include <math.h>
    #include <limits.h>
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    typedef struct node
     struct node *left, *right;
     int value;
     char** lines;
     int line;
    int main(int argc, char *argv[])
     node *tree;
     FILE *pFile;
     char *cache;
     char* text = *(++argv);
     int count = 0;
     tree = malloc(sizeof(node));
     tree->left = NULL;
        tree->right = NULL;
        tree->value = 100;
     tree->lines = malloc(sizeof(char));
     cache = malloc(sizeof(char) * 100);
     pFile = fopen(text,"r");
     while ( !feof(pFile) )
      tree->lines = realloc(tree->lines,(count+2)*sizeof(char*));
      tree->lines[count] = malloc(strlen(cache) + 1);
     tree->line = count - 1;
     for(count = 0; count < tree->line; count++)
      printf("%s", tree->lines[count]);

The following order represents the importance of errors. If multiple errors occur only the most important one should be shown and the command should then be canceled.
1. Wrong calling of the program (too many arguments):
Usage: ./ass1 [file-name]\n
Return: 1
2. If storage is not enough while the program is running, this should be shown:
[ERR] Out of memory.\n
Return: 2
3. If there is a problem with the reading of files during the program start (non existing file or damaged file), the program should be canceled as follows:
[ERR] Could not read file [filename].\n
Return: 3
The following error should not cancel the command
- If the users enters something different than A or B.
[ERR] Please enter A or B.\n
I want to create functions for the error cases and found the errno.h library, and read something about perror, but I am new to coding and I have no clue what to do next as my implementation does not work.
Thanks for your effort.