int readStopList(FILE *stopFile, char ***stopList)
{
int w;
char wrd[MAX_STR_LEN]; // #define MAX_STR_LEN 128 (defined above)
/* count words in stoplist */
w=0;
while (nextWord(stopFile,wrd)!=EOF) w++;
*stopList=(char **)calloc(w,sizeof(char*));
rewind(stopFile);
w=0;
while (nextWord(stopFile,wrd)!=EOF) {
unsignedint c;
(*stopList)[w]=(char *)calloc(strlen(wrd),sizeof(char)); // Here's the problem
for (c=0; c<strlen(wrd); c++) (*stopList)[w][c]=wrd[c];
(*stopList)[w][c]='\0';
w++;
}
return w;
}
The problem seems to be in calloc () but I tried to free() and delete[] "wrd" and "stopList" but nothing.. It is very rare, sometimes works and sometimes not. Please any help...