0

where is the root of my problem? After running check50, it detected following errors:

:) dictionary.c, dictionary.h, Makefile exist
:) speller compiles
:( handles most basic words properly
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 326..."
:( handles min length (1-char) words
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 325..."
:( handles max length (45-char) words
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 325..."
:( spell-checking is case-insensitive
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 326..."
:( handles possessives properly
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 327..."
:( handles substrings properly
\ expected output, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 326..."

Meanwhile, I get a segmentation fault after run code on Speller Austin Power.

By guessing problem is in Check, below is my code:

0

Your check function has some critical issues. It needs to walk the trie to the last node of the word, but has no way to determine when it has found it so that it can check the is_word flag. Instead, you are setting the flags in each node along the way to true.

The code is also incrementing wordcount.

The check function should not be making any alterations to data in the dictionary trie, only looking at the data. wordcount is only for counting words in the dictionary processed by load. The word count of the checked text is handled in main.

You might also want to review the tolower() function.

While not a comprehensive analysis, this should get you going again.

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

1
  1. Also, for navigating the trie, instead of defining a new node next_node:

    struct node* next_node = arrow->child[index];

you can just move the arrow pointer like so:

 arrow=arrow->child[index];
  1. And as Cliff B alluded to above, your c is not incrementing, you are stuck at c=0, the first letter of the word. Maybe you meant to increment c and not word_count?
  • Thanks Pals!! Cliff, your advices made important adjustments throughout my code (Check & Load). Ronga your advice made my code cleaner. Now it works properly :) – cocobongo Mar 31 '16 at 16:31

You must log in to answer this question.

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