Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

imageimageimage

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

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

Microeconomics

Authors: David Besanko, Ronald Braeutigam

5th edition

1118572270, 978-1118799062, 1118799062, 978-1118572276

More Books

Students also viewed these Programming questions