0

My speller code works fine, I've compare it with the staff solution with different texts and dictionaries and everything is exactly the same (words in dictionary, words misspelled, words in text) but still it fail to pass check50.

The complete summary of check50 give me this line in every test my code failed:

"Conditional jump or move depends on uninitialised value(s): (file: dictionary.c, line: x)"

For example, im getting that error in this if statement located in my load function.

    // create new nodes if its necessary
    // if not, parse the trie to the next node
    if (trav->children[i] == NULL) // can a pointer be NULL by default?
    {
        trav->children[i] = malloc(sizeof(struct node));
        trav = trav->children[i];
    }
    else
    {
        trav = trav->children[i];
    }

btw mi code doesn't leak any memory

  • I believe it could be NULL by default if you use calloc() instead of malloc(). Could you show what valgrind exactly says? – obesman Aug 2 '17 at 16:54
  • Yes! Using calloc instead of malloc correct the issue. Thanks! – Luis César Aug 2 '17 at 17:31

You must log in to answer this question.

Browse other questions tagged .