I am working on a programming assignment in C, which is about creating basic automation for cinema halls.
For holding data of halls, I define a structure like this:
typedef struct {
 char *hallName;
 char *movieName;
 seat** hallSeats;
 int studentCount;
 int fullFareCount;
 int totalSum;
 int width;
 int height;
}Hall;
So I am given a text file with commands and whenever I came up with a specific command, I should create a separate hall. For that reason, I created another function for that.
Hall makeHall(char **temp)       //TEMP HOLDING THE LINES FROM FILE
 {
    int width = strToInt(temp[3]);
    int height = strToInt(temp[4]);
    char currentRowLetter = 'A';
    int currentRow;
    int currentSeat;
    seat **hall = malloc(sizeof(seat*) * width );
    for (currentRow=0 ; currentRow < width ; currentRow++)
    {
         hall[currentRow] = malloc(sizeof(seat) * height );
        for(currentSeat=0; currentSeat < height ; currentSeat++)
        {
            hall[currentRow][currentSeat].rowLetter = currentRowLetter;
            hall[currentRow][currentSeat].seatNumber = currentSeat + 1;
            hall[currentRow][currentSeat].seatTaken = ' ';
        }
        ++currentRowLetter;
    }
    Hall newHall;
    newHall.hallName = temp[1];
    newHall.movieName = temp[2];
    newHall.hallSeats = hall;
    newHall.width = width;
    newHall.height = height;
    return newHall;
}
Since I will have multiple halls, I created a Hall array in order to access them later.
    Hall *allHalls = malloc(sizeof(Hall) * 10);    /*Hall placeholder*/
While I iterate over the lines, I check commands and create halls or sell tickets.
Hall *allHalls = malloc(sizeof(Hall) * 10);                       /*Hall placeholder*/
FILE *f;
f = fopen("input.txt", "rt");
char *line = malloc (sizeof(char) * 200);   /*LINE HOLDER*/
int currentLineNumber = 0;
char *tmp;
int hallNumber = 0;
while (1) {     /*PARSING FILE*/
    if (fgets(line,200, f) == NULL) break;      /*FILE END CHECKER*/
    currentLineNumber++;
    tmp = strtok(line," ");
    char **temp = malloc(sizeof(char*) * 6);
    int currentWordNumber = 0;
    while(tmp != NULL)     /*PARSING LINES*/
    {
        temp[currentWordNumber] = malloc(strlen(tmp) + 1);
        strcpy(temp[currentWordNumber],tmp);
        tmp = strtok (NULL, " ");
        currentWordNumber++;
    }
    if(!strcmp("CREATEHALL",temp[0]))  
    {
        allHalls[hallNumber] = makeHall(temp); /*<<<<<<<PROBLEM*/
        hallNumber++;   
        printf("%d\n",hallNumber);
    }
Now that's the part I am lost at. Whenever I tried to access the array, the program crashes.
I thought it was a memory problem, so increased memory allocated by malloc for allHalls to 40 (even though it should not be a problem, since file only gives 3 different halls) and program no longer crashes, but instead overwrites the previous hall in the array.
I tried multiple solutions but none of them came out any good, so closest I get is this.
I did use java a lot before, so I am still stuck to OOP and pretty new to C.
EDIT Seat is defined as
typedef struct {
char rowLetter;
int seatNumber;
char seatTaken;
}seat;
also example createhall command is
CREATEHALL Hall_A Avatar 24 20
while the numbers at the end being width and height for hall
EDIT : CODE
seatdefined?seat.tmpis initialized fromstrtok