So I need to scan in a dictionary of words, max length 19 and dynamically allocate memory to set the size of the dictionary array. I am stuck on how to do this.
fscanf(ifp, "%d", &numwords); //Number of words in dictionary
char ** dictionary;
for(i = 0; i < numwords; i++){
for(j = 0; j < 20; j++){
dictionary[i][j] = (char *) malloc(20 * sizeof(char));
fscanf(ifp, "%s", &dictionary[i][j]);
//printf("%s\n", dictionary[i]); //tests that the letter is read in correctly
}
}
I am lost on what is wrong. Any help would be greatly appreciated.