I am trying to input a file into a two-dimensional array but I am getting a seg fault when trying to find the max line length and the max number of lines. The seg fault occurs in the function checkSpelling. I have tried using gdb to see where the seg fault occurs but I am getting that it exits right away which I don't completely understand. My code is below. Any help is greatly appreciated.
#define MAX 1000000
struct TData{
    char **pChar;
};
int checkSpelling(const char *input, const char *dict, struct TData *pInput, struct TData *pDictionary);
int searchReplace(const char *input, const char *dict, struct TData *pInput, struct TData *pDictionary);
int save(const char *input, const char *output);
int main (int argc, char **argv){
    struct TData input, dictionary, output;
    int choice = 0;
    if(argc != 4){
            printf("Not enough input arguments in the command line.\n");
            exit(1);
    }
    do{
            printf("Menu\n");
            printf("1. Check the spelling for the file using the dictionary.\n");
            printf("2. Search and replace a given string in the inputed file.\n");
            printf("3. Save the modified file to the output file.\n");
            printf("4. Exit the program.\n");
            scanf("%d", &choice);
            switch(choice){
                    case 1:
                            checkSpelling(argv[1], argv[3], &input, &dictionary);
                            break;
                    case 2:
                            searchReplace(argv[1], argv[3], &input, &dictionary);
                            break;
                    case 3:
                            save(argv[1],argv[2]);
                            break;
                    case 4:
                            choice = 4;
                            break;
                    default:
                            printf("Input is invalid");
                            break;
            }
    }while (choice != 4);
return 0;
}
int checkSpelling(const char *input, const char *dicto, struct TData *pInput, struct TData *pDictionary){
    FILE *inputFile;
    FILE *dictFile;
    int i = 0, j = 0, k = 0, l = 0, m = 0;
    char temp[60], dicttemp[60];
    int rowCount = 0, charCount = 0;
    printf("Checking the spelling of the inputed file.\n");
    printf("Opening the inputed file...\n");
    if((inputFile = fopen(input, "rt")) == NULL){
            printf("Cannot open file\n");
            exit(1);
    }
    printf("Opening the dictonary...\n");
    if((dictFile = fopen(dicto, "rt")) == NULL){
            printf("Cannot open dictionary\n");
            exit(1);
    }
    while(!feof(inputFile)){
            if(pInput->pChar[i][j] == '\n'){
                    rowCount++;
            }
    }
    rewind(inputFile);
    pInput->pChar[i][j] = 0;
    while(pInput->pChar[i][j] != '\n'){
            charCount++;
    }
    rewind(inputFile);
    printf("Lines: %d, Max line length: %d", rowCount, charCount);
    fclose(inputFile);
    fclose(dictFile);
    printf("\n");
return 0;
}
 
    