Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2. Find and Replace (30 points) Suppose, you have a string S1. There is a chance that a smaller string $2 is present within

image text in transcribed
Problem 2. Find and Replace (30 points) Suppose, you have a string S1. There is a chance that a smaller string $2 is present within S1. You want to find out the place where S2 occurred and replace S2 with another string S3. Thus, you have a new S1. For example, S1- "One Sunny Day", S2-"Sunny" and S3-"Cold". After finding S2 in S1 and replacing it with S3, we get S1-"One Cold Day". Write a program that takes 3 strings as inputs and changes the first string using the find and replace method mentioned. You are not allowed to use any string variables other than 3 input strings. Include string.h, stdlib.h. Take 3 strings as inputs properly. You might want to find out the first occurrence of S2 in S1, using built-in function. After that, use conditional statements and loops for properly removing S2 from S1 and inserting S3. Keep in mind that S2 and S3 can be of different size. If you use fgets() in this problem, use strtok (string name, "In"): after each fgets() Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs) Sample Input Sample Output After Replacing: Howdy, World Enter $1: Hello, World! Enter S2: Hello Enter S3: Howdy After Replacing: I am THE danger Enter S1: I am not in danger Enter S2: not in Enter S3: THE After Replacing: Oh Captain! Our Captain Enter S1: Oh Captain! My Captain Enter S2: My Enter S3: Our

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

]. Did you think the presentation was effective? Why or why not?

Answered: 1 week ago