Assignment 29: Searching for words
due Monday 5/13
The ability to search for information is a powerful feature in many computer programs.
This assignment is to write a simple kind of search program.
Here is what your program should do:
- Allow the user to enter a sequence of words into an array words,
which must have the apvector<apstring> type. (Like in
the second part of Assignment 28, ask the user to first enter the array's size,
then the array's contents.)
- Ask the user to enter a search word.
- Tell the user where in the array their search word can be found. Correctly handle
cases where the string occurs at more than one place in the array, or not at all.
Please make your output statements look like these examples:
Found once:
"Computer" found in words[4].
Found more than once:
"Computer" found in words[4].
"Computer" found in words[11].
Not found:
"Computer" not found.
Sample runs: Include at least three runs, with the search word being found
exactly once, more than once, and not at all.
Extension
Enable the program to match substrings within a string.
For example, if the user searches for "put", it would be found within the string
"Computer". You'll need to read ahead in the strings chapter to learn
a function that finds strings inside other strings -- see section 12.5 in particular.