Question: 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

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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!