Question: Objective: The find function for strings only returns the first instance of a character or a word. In this lab, you will create your own
Objective: The find function for strings only returns the first instance of a character or a word. In this lab, you will create your own approach to return all instances of a character or a word in a string. Write a program called lab5.cpp which can allow the user to find all instances of a character or a word in a string. For this lab, you can use the following string in your program std: string mystr "the quick brown fox jumped right over the lazy dog."; Your program should prompt the user to enter a character or a phrase and print to the screen the positions of the character or word within the string. If the character or phrase was not found, your program should print to the screen the message Not found To submit your program use the following: Your output should look like the example shown below bash-4.1$ ./stringfind Enter a character or a word: t 0,31,38, bash-4.1$ ./stringfind Enter a character or a word: the 0,38, -bash-4.1s ./stringfind Enter a character or a word: hello Not found bash-4.1S Figure 1 - Multifind program showing the program returning positions of a character or a word within the string, and a message Not found if it cannot find it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
