Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

B. Searching in a String In this program, you will use a string function to determine whether a user selected sub- string is present in

image text in transcribed

B. Searching in a String In this program, you will use a string function to determine whether a user selected sub- string is present in a larger string or not. 1. Declare and initialize a string with the following text: This is a lab in CSCE 1030 based on strings. 2. Declare another string variable to store the sub-string you want to search in the larger string. 3. Using a suitable message, ask the user for the sub-string. You many assume the user will only enter a single word to search. 4. Using the member function find(), determine the location of the sub-string in the larger string. 5. Inside an if-else block, check if the computed location is a valid index. a. If it is a valid index, display the location of the substring with a suitable message. Note at just comparing the location with -1 is not sufficient. Think what the valid range indices for a string is and use that in your if-else condition. b. If it is not a valid index, display a suitable error message

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

b. Will there be one assigned leader?

Answered: 1 week ago