Faisal K.

asked • 05/12/20

practice using dynamic memory allocation, c-string functions,

Read a dictionary word file into an array of c-strings. 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.

Program Requirements

  1. Use these files for your dictionary and the final spell check test.
  2. Use an array of char pointers store your word file.  Allocate memory dynamically to store each word in a char array.  Store the dictionary words in lower case.
  3. Use a temporary char array to hold each line in the test file. “Parse” each line into individual words for spell checking. not use the stringstream classes
  4. Spell checking must ignore case. For example, “Hello” is the same as “hello”.
  5. If the word ends in s, then you must also check the word with the s removed. For example, years is not misspelled because year is in the dictionary.

Program Output

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, nation's on line 13

Misspelled word, tranquilizing on line 28

Misspelled word, gradualism on line 29

Misspelled word, God's on line 31

Misspelled word, Negro's on line 35

Misspelled word, whirlwinds on line 41


There should be slightly more than 20 misspelled words.

  1. For your dictionary sort, you can "swap pointers" since you are working with an array of pointers.
  2. Use strtok() for the parsing of each line.


1 Expert Answer

By:

Patrick B. answered • 05/17/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.