0

I just moved on to pset5 and am finding a little difficulty. I believe I have implemented the correct code for dictionary.c but having searched through, I am getting a set fault during check. Unfortunately, I have no idea where the problem lies anyhow to fix it. Any help would be thoroughly appreciated!!

Here is my code:

enter image description here enter image description here Here is the error that appears

Thank you so much!!

5
  • Hey Junho: This looks like a job for gdb! When you don't know where the problem lies, gdb can usually tell you. Well, not the exact answer of course, but it should get you to the place you need to look. Suggest setting a break at check and "next-ing" through. – DinoCoderSaurus Oct 31 '15 at 17:03
  • How would I set a break at check in dictionary.c when I'm running speller.c. Also, when I try to run gdb, it returns: [inferior 1 (process 6434) exited with code 01 – Junho Choi Oct 31 '15 at 19:10
  • Just try it! Since dictionary.h is #include -ed in speller.c it's in there! Remember to send your arguments to speller at your run command (in gdb). – DinoCoderSaurus Oct 31 '15 at 19:42
  • Thank you!! Now I can check a bit more thoroughly – Junho Choi Oct 31 '15 at 21:13
  • Run this commands into the terminal to debug your program: -gdb ./speller -break check -run texts/alice.txt (or w/e text you wish to spell check) -next and keep next-ing until you find the seg fault line. – Mahmoud Khaled Sep 10 '16 at 1:31
0

You first call tolower(c) (c is 0 at the time), and then you copy word[i] into c. As soon as the first word in the text is loaded (which is likely to be capitalized), where in the array will you be?

Also, why are you looping till EOF? Where will EOF be? And the fact that a char isn't a digit doesn't mean that it's a letter from the alphabet :)

You must log in to answer this question.

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