0
bool load(const char *dictionary)
{
    char splitStrings[9999][45];
    FILE* dict = fopen(dictionary, "r");

    node* item = table[0];

    int i = 0;
    for (i = 0; fscanf(dict, "%s", splitStrings[i]) != EOF; i++)
    {
        strcpy(item -> word, splitStrings[i]);
        item = item -> next;
    }

    return true;
}

my code adds all words to table[0] (i know it's not efficient) but when i try to use strcpy to add the word, i get a SIGSEGV / segmentation fault / core dump. i cant figure out the problem.

2 Answers 2

0

Based on the distro codetable is an array of node pointers, not an array of nodes. Therefore, there is no item->word. If this program is different from the distro code in that respect, please edit into the question the necessary information.

0

In this code,

strcpy(item -> word, splitStrings[i]);

if you're getting a seg fault, it's highly likely that either item->word or splitStrings[i] doesn't exist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .