resumos/cursos/cs50/all-challenges/problems/speller/speller.c
bool load(const char *dictionary)
{
    FILE *dictionaryFile;
    dictionaryFile = fopen(dictionary, "r");
    char word[LENGTH];

    if (dictionaryFile == NULL)
    {
        fputs("File error ", stderr);
        return false;
    }

    while (fscanf(dictionaryFile, "%s", word) == 1)
    {
        node *n = malloc(sizeof(node));

        if (n == NULL)
        {
            return false;
        }

        // Copy word into node
        strcpy(n->word, word);
        n->next = NULL;

        // call hash function
        unsigned int hashIndex = hash(word);

        n->next = table[hashIndex];

        table[hashIndex] = n;
        wordsInDictionary++;
    }
    fclose(dictionaryFile);
    return true;
}
// Loads dictionary into memory, returning true if successful, else false

Loads dictionary into memory, returning true if successful, else false
Loads dictionary into memory returning true if successful else false
bool load(const char *dictionary)
{
    FILE *dictionaryFile;
    dictionaryFile = fopen(dictionary, "r");
    char word[LENGTH];
    if (dictionaryFile == NULL)
    {
        fputs("File error ", stderr);
        return false;
    }
    while (fscanf(dictionaryFile, "%s", word) == 1)
    {
        node *n = malloc(sizeof(node));
        if (n == NULL)
        {
            return false;
        }
        strcpy(n->word, word);
        n->next = NULL;
        unsigned int hashIndex = hash(word);
        n->next = table[hashIndex];
        table[hashIndex] = n;
        wordsInDictionary++;
    }
    fclose(dictionaryFile);
    return true;
}
bool load ( const char * dictionary ) { FILE * dictionaryFile ; dictionaryFile = fopen ( dictionary , " " ) ; char word [ LENGTH ] ; if ( dictionaryFile == NULL ) { fputs ( " " , stderr ) ; return false ; } while ( fscanf ( dictionaryFile , " " , word ) == 1 ) { node * n = malloc ( sizeof ( node ) ) ; if ( n == NULL ) { return false ; } strcpy ( n -> word , word ) ; n -> next = NULL ; unsigned int hashIndex = hash ( word ) ; n -> next = table [ hashIndex ] ; table [ hashIndex ] = n ; wordsInDictionary ++ ; } fclose ( dictionaryFile ) ; return true ; }
Loads dictionary into memory, returning true if successful, else false
Loads dictionary into memory returning true if successful else false
// Copy word into node
 // call hash function
