Question: Complete the function substr which works similar to the C++ version of substr. You pass a starting index and a length to be copied

Complete the function substr which works similar to the C++ version ofsubstr. You pass a starting index and a length to be copiedto dest. If there are fewer characters in src then only copy

Complete the function substr which works similar to the C++ version of substr. You pass a starting index and a length to be copied to dest. If there are fewer characters in src then only copy those. cstrings.cpp 1 /** 2 3 4 5678 unpBH15 16 7 18 10 8 */ 9 char* substr(char* dest, const char * src, int pos, int count) 10 { 11 int i=0; 12 13 14 19 } CodeCheck Testers Extracts a substring from an existing C-string. @param dest the C-string containing the substring. @param src the C-string to copy from. @param pos the index to start with. @param count the number of characters to copy. @return a pointer to the modified string. while(src[i]!='\0') { dest[i]=src[i+pos]; } i++; 2/5 return dest; Running Tester.cpp fail pass fail pass fail Score Reset substr(d, "improvement", 1, 2): mprovement Expected: mp substr(d, "host", 2, 3): st Expected: st substr(d, "south", 0, 1): southement Expected: s substr(d, "someone", 3, 1000): eone Expected: eone substr(d, "comedy", 3, 0): edy Expected: Complete the function stricmp which works like strcmp but compares strings without regard to case. Thus "cat" and "CAT" are equal. You may use the toupper and tolower functions in your code. cstrings.cpp 1 2 3 #include using namespace std; /** 4 5 6 7 8 */ 9 int stricmp(const char* s1, const char* s2) 10 { 11 12 } Compares two C-strings case-insensitive. @param s1 the left side C-string. @param s2 the right side C-string. @return 0 if equal, -1 if s1 < s2, +1 if s1 > s2. CodeCheck Reset Fill in the missing parts in the program below. cmdline.cpp 1 2 3 4 5 6 7 8 9 10 #include using namespace std; fail int main(int argc, char* argv[]) { CodeCheck } 3 15 cout < < "Program " < < argv[0] < < endl; cout < < < "# of arguments

Step by Step Solution

3.46 Rating (153 Votes )

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 Programming Questions!