0
bool load(const char* dictionary)
{
    FILE* fp=fopen(dictionary,"r");

    if (fp==NULL)
    {
        printf("Could not open dictionary");
        return 2;
    }
    for (int i=0;i<SIZE;i++)
    {
        hashtable[i]=NULL;
    }
    while(feof(fp)==0)
    {
        //malloc a new node
        node* new_node=malloc(sizeof(node));
        //taking word from dictionary
        fscanf(fp,"%s",new_node->word);
        //passing the word to hash fn()
        int x=hash_function(new_node->word);
        if (hashtable[x]==NULL)//Conditional jump or move depends on uninitialised value(s)
        {
            hashtable[x]=new_node;
        }
        else
        {
            new_node->next=hashtable[x];
            hashtable[x]=new_node;
        }
    }
    fclose(fp);
    return true; 
}

int hash_function(char *key)
{
    // hash on first letter of string
    int hash = toupper(key[0]) - 'A';//Conditional jump or move depends on uninitialised value(s)
    return hash%SIZE ;
}
2
  • Please help ??? Jul 27 '16 at 15:10
  • looked at it, couldn't duplicate it. Can you post all of the global declarations. particularly for hashtable?
    – Cliff B
    Jul 28 '16 at 6:29

You must log in to answer this question.

Browse other questions tagged .