0

No sure where the problem is : https://sandbox.cs50.net/checks/58b8a6fbbc464ad88eb9e8ac9ba16d37

:) dictionary.c, dictionary.h, Makefile exist
:) speller compiles
:( handles most basic words properly
   \ expected output, but not "\nMISSPELLED WORDS\n\nThe\n\nWORDS MISS..."
:) handles min length (1-char) words
:) handles max length (45-char) words
:( spell-checking is case-insensitive
   \ expected output, but not "\nMISSPELLED WORDS\n\nfoO\nfOo\nFoo\nfO..."
:) handles possessives properly
:) handles substrings properly

Note : I am using strcasecmp() in check and my fash function is djb2

My check function

bool check(const char *word)
{
    node *checker = malloc(sizeof(node));
    // determine in which index(bucket) is the word
    int index = hash(word);
    checker = hashtable[index];

    while(checker != NULL)
    {
        // checker is case insensitive
        if(strcasecmp(checker->word, word) == 0)
            return true;
        checker = checker->next;    
    }
    return false;
}
1
  • This is my load function :
    – ravi s
    Jun 1 '17 at 5:18
0

When your hash function hashes the word, is it converting it to all lower case first? If not, it won't hash any words with upper case letters correctly.

If this isn't the problem, please edit your question and add the code for the hash function and for load there.

BTW, you have a memory leak in your check function. ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

3
  • It was the hash function thank you. I was using one of the standard built one but then i used my own.
    – ravi s
    Jun 3 '17 at 2:41
  • I am now having problem with valgrind.
    – ravi s
    Jun 3 '17 at 2:42
  • Well, that would be a new question. ;-)
    – Cliff B
    Jun 3 '17 at 4:54

You must log in to answer this question.

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