0

i believe my load function is already working properly, i use fgets, and i have deleted the newline character in each word.

but when it comes to check (i think..) it gives me unrelated output. this is the output

MISSPELLED WORDS

.

It's Mispelled!.. probably

zooms

It's Mispelled!.. probably

zombie

It's Mispelled!.. probably

zoo

It's Mispelled!.. probably

zoo

i've checked the dictionaries/large, and it's most definitely contain those words, and that output even spit out "zoo" 2 times.. i'm super confused now.. please help!

this is my check code:

bool check(const char* word)
    {
        // TODO
        int code2 = hash(word); //hashed of input
        node* crawler = bucket[code2];
        if(crawler == NULL)
        {
            printf("NOthing!\n");
            return false;
        }

        while(true)
        {  
            if(crawler != NULL)
            {
                if(strcmp(crawler->word, word) == true)
                {
                    //printf("Exist! - %s\n", word);
                    return true;
                }
                else
                {
                    crawler = crawler->next;
                }
            }
            else
            {
                printf("It's Mispelled!.. probably\n");
                return false;
            }
        }
        return false;
    }
1

The strcmp() function doesn't return a bool (true/false), it returns a number, depending on whether they are equal, or depending on which is "greater". If they are equal, strcmp returns 0. Unfortunately, a 0 is interpreted as false.

There may be other issues, but this is probably the biggest one.

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

You must log in to answer this question.

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