Your problem was this, I imagine:
You don't free any of your data.Code:/* Open menu file for reading. */ fp1 = fopen(menuFile, "r"); /* check if fp1 menu file exists*/ if(fp1 == NULL) { printf("file error\n"); /* should exit the function */ } /* initialize the previous node to NULL*/ prevCat = NULL; while((line = fgets(array, BUFFER_SIZE + 2, fp1)) != NULL) {