I have a struct in my main.h but when I try to allocate memory for the 3D array in the struct, I get the following compiler error.
'text' has no member named 'list'
Now, I only get this for the 3D array the the other variables in the struct.
main.h
#define MAX_WORD 100
typedef struct textTag {
char name[100];
char ***list;
int words;
}text;
main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
void createArray(FILE *file, text *checkTexts, int fileCount, int size){
int i, n, wordCount, sections, rest;
FILE *textFile;
text localText;
char fileName[MAX_WORD + 30];
readFileNames(file, checkTexts);
for(i = 0; i < fileCount; i++){
localText = checkTexts[i];
strcpy(fileName, "./testFolder/");
strcat(fileName, checkTexts[i].name);
openFile(&textFile, fileName);
checkTexts[i].words = countWords(textFile);
sections = (wordCount / size);
rest = wordCount % size;
checkTexts[i].list = malloc(sections * sizeof(char **)); //Compile error here
for(n = 0; n < sections; n++){
checkTexts[i].list[n] = malloc(size * sizeof(char *)); //Compile error here
}
checkTexts[i].list[sections] = malloc(rest * sizeof(char*)); //Compile error here
readFileContent(textFile,checkTexts[i].list, size); //Compile error here
}
}
Like I said in the comment.
Fixed the problem
It was a stupid mistake be my self, where i had accidently opened the wrong main.h file, so I was editing a file for an other project, so the struct i was using did indeed not have en member list.
But thanks for trying to help me.