Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

String Processing in C programme Complete the following function for inserting a string fragment into an original string at a specified position. char *strInsert(char *original,

String Processing in C programme

image text in transcribedimage text in transcribed

Complete the following function for inserting a string fragment into an original string at a specified position. char *strInsert(char *original, char *fragment, int position) OR, alternative notation char *strInsert (char original[], char fragment[], int position) Note that a char pointer can be used to point to the starting location of a char array It assumes the original string has enough room to accommodate the string fragment. Both string parameters shall be properly NULL-terminated. The fragment shall be inserted into the original string starting at index position. If the position parameter is negative, let it be zero, that is, prepend the fragment to the original string. If the position parameter is larger than the original string length, append the fragment to the end of the original string. It returns a pointer representing the result string, i.e., the original string Hint: you may use string functions, however, please mind that the data type size_t employed is NOT int!I You shall apply type casting before comparing a size_t value with an int Sample Run #1 Input original string Happy day Input fragment string: birth Input position: BEFORE strInsert(), Original string: [Happy day] BEFORE strInsert(), Fragment string: [birth] strInsert return [Happy birthday] AFTER strInsert(O, original string: [Happy birthday] AFTER strInsert), Fragment string: [birth] Sample Run #2 Input original string: Happy day Input fragment string Hi Input position: -100 BEFORE strInsert(), Original string: Happy day] BEFORE strInsert(), Fragment string: [Hi, ] strInsert return [Hi, Happy day] AFTER strinsert(), Original string: [Hi, Happy day] AFTER strInsert), Fragment string: [Hi,]

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Question Can a Keogh plan fund be reached by the owners creditors?

Answered: 1 week ago

Question

Question What happens to my plan if I die?

Answered: 1 week ago