4 - Spell Checker
purpose of this assignment is to give you practice using dynamic memory
allocation, c-string functions, sorting, and searching. You
will write a spell
checking program and test it.
Read a dictionary
word file into an array
You will need to dynamically allocate memory for each word
in the dictionary.
The word file contains 23,907 words.
Sort the dictionary.
Reading in a test file,
one line at a time. Parse the line to get each individual
word in the line. Search the dictionary word
list (the array of c-strings) for each word in the line.
If the word
is not found, print a message. The search should be performed
as a binary search.
- Use these files
for your dictionary and the final spell check test.
- Use an array of char pointers store your word
memory dynamically to store each word in a char array. Store
the dictionary words in lower
- Use a temporary char array to hold each line in
test file. “Parse” each line into individual words for spell
checking. Note, you may not
use the stringstream classes for this assignment.
checking must ignore case. For example, “Hello”
is the same as “hello”.
the word ends in 's or s, then you must also check the word with the 's
or s removed. For example, nation's is not misspelled, because
nation is in the dictionary, and years is not misspelled because year
is in the dictionary.
Your output should looks quite similar to this:
|Misspelled word, withering on line 4|
Misspelled word, captivity on line 5
Misspelled word, dramatize on line 12
Misspelled word, 'tis on line 102
Misspelled word, Alleghenies on line 107
Misspelled word, snowcapped on line 108
There should be less than 20 misspelled words.
- Follow the program steps. Write
only one part of the program at a time. Test each part before
proceed to the next step. Do not continue if one part has a
problem. Ask for help with a step, if you can't get it to
Remember to allow plenty of time for this assignment.
- Use a small dictionary
and a small test file
initially as you are developing your code.
- For your dictionary sort, you can "swap pointers" since you are working with an array of pointers.
- Use strtok() for the parsing of each line.
- Xcode users: There is a \r at the end of each line in the test
file. You can suppress it by adding "\r" as a delimiter for
- Don't code the search for the 's and s endings until you get the rest of the search working.