1

1) The rules state I can't change speller.c

2) Speller.c sends each word to the check function in dictionary.c

3) I am creating a copy of that word in my function and making it all lower-case

4) I am returning true if it's in my dictionary, false if not

5) I am not changing the number of words sent to the check function: the length of the word, the letters in the word, the number of words is the same

6) Staff says 295 words are misspelled, I get 125 (alice.txt)

Staff's:

ALICE'S

skurried

O

O

O

Ou

chatte

My solution:

ALICE'S

skurried

Staff's solution:

pglaf

org

c

c

http

My solution:

pglaf

http

-1

EDIT: The second paragraph is my first answer, which is a workaround for having strlen report the incorrect length of the current-word (1 more than actual). You can make it work with strncmp and a lot of conditions and assumptions. Then in Prof. Malan's lecture on Python (week 8) he mentioned stripping out the newline '\n' and this problem popped into my head. I went back to my code and found that I was picking up and adding the newline character to my linked-list. I found a bunch of ways to remove it here (I picked strtok): https://stackoverflow.com/questions/2693776/removing-trailing-newline-character-from-fgets-input

In the Check() function, you have a few options. I noticed my dictionary stored as a linked-list was slightly off in that each word was being reported by strlen() as 1 longer than it actually is. So if the current->word was "dog", strlen(current-word) would output 4. I tried fixing this and found the strncmp function and didn't read enough about how it worked. If the word in the story is "tm", which has a length of 2, strncmp will say that it is equal to "tmesis" (which is in the dictionary).

2
  • strlen() does NOT report the incorrect length of the current word. It correctly returns the length of the string you give it. And if you give strlen() a string which is one character longer than the word, it will still return the length of the string you gave it, rather than the length of the string you would have liked to give it. – Peter Pesch Oct 7 '18 at 9:08
  • strncmp() will NOT say that "tm" is equal to "tmesis". But if you ask it to compare only 2 characters, it will correctly report that the first 2 characters of "tm" are the same as the first 2 characters of "tmesis". – Peter Pesch Oct 7 '18 at 9:12

You must log in to answer this question.

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