Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Loads dictionary into memory, returning true if successful else false
- bool load(const char *dictionary)
- {
- FILE *file = fopen(dictionary, "r");
- if (!file)
- {
- return false;
- }
- char* word = malloc(LENGTH);
- word = NULL;
- while (fscanf(file, "%45s", word) != EOF)
- {
- node *n = malloc(sizeof(node));
- n->next = NULL;
- if (!n)
- {
- return false;
- }
- strcpy(n -> word, word);
- int index = 0;
- index = hash(word);
- n->next = table[index];
- table[index] = n;
- free(n);
- SIZE += 1;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement