Lab Assignment #6
Due Thursday, August 14 at the beginning of class
The assignment is to write a spell-checking program in C++. The program will prompt the user for 3 different filenames. The first prompt is for the name of a file to be used as the dictionary. The second prompt is for the name of the file that contains the words to be checked. The third prompt is for the name of an output file. The output file will contain the results of the spell-check. This is a sample of what your program should look like when it is run:
Enter the name of the dictionary file: lexicon.txt
Enter the name of the file to check: fruits.txt
Enter the name of the file to write the output: program6.out
You must follow this format exactly. I will be using an automated script for all prompts.
Details
- The program must handle words in the dictionary and words in the input file that are up to 20 characters in length.
- You can assume that the longest filename is 50 characters.
- You must test whether or not opening of a file was successful. DO NOT re-prompt the user if a file cannot be opened. The easiest method here is to use the assert() function we have discussed. That will terminate the program with an appropriate error message. Again, I will be automating the testing process and will purposely enter filenames that don't exist.
- You must allow uppercase and lowercase words to be considered the same. You may want to use the my_strupr() function that we did in class. DO NOT use the library function strupr(), as it is not available on all platforms.
- Don't try to read the words from the dictionary file into an array. You don't know how many words are in the dictionary, and there may be over 100,000. The same is true for the file you are checking: don't read the input words into an array.
- TEST YOUR PROGRAM. Does your program run if there are no words in the dictionary? What if there are no words in the input file? Your program should work correctly in both cases.
Here is a sample of what the contents of the three files might look like:
Dictionary Input file Output file
(lexicon.txt) (fruits.txt) (program6.out)
-----------------------------------------------------------------------------------
pear banana apple Not found: pearh
peach pineapple pearh Not found: bananna
mango apple lime bananna Not found: peech
lemon peech Not found: plum
orange pineapple Not found: manog
grapefruit plum Not found: grapefroot
avocado manog
grape LEMON Number of words not found in dictionary: 6
LIME
grapefroot
How to submit your programs
Back to Outline