My guess is that the file is failing to open, and you're still passing it to fgets. Your if(rd==NULL) doesn't stop execution of the fgets if it's null, it just prints out a message and continues with execution.
Some very basic errorr handling:
const char* frd = "word-list.txt";
FILE *rd=fopen(frd,"r");
if(rd==NULL) {
std::cout<<"Coudn't open file"<<endl;
return 1;
}
char readLine[100];
while(fgets(readLine, 100, rd) != NULL)
{
readLine[strlen(readLine) - 1] = '';
char *token = NULL;
token = strtok(readLine, " ,");
insert(readLine);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…