Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started