Question: / Description: // This file tests the lab section of your workshop /////////////////////////////////////////////////// #include #include cstring.h using namespace std; using namespace sdds; int main() {

/ Description:

// This file tests the lab section of your workshop

///////////////////////////////////////////////////

#include  #include "cstring.h" using namespace std; using namespace sdds; int main() { char str1[80] = "abcdefghijklmnopqrstuvwxyz"; char str2[80]; const char* fadd; strCpy(str2, str1); cout << str2 << endl; strnCpy(str2, "@@@", 2); cout << str2 << endl; strnCpy(str2, "@@@", 3); cout << str2 << endl; strnCpy(str2, "@@@", 4); cout << str2 << endl; cout << strCmp("aab", "aaa") << endl; cout << strnCmp("aab", "aaa", 2) << endl; cout << strnCmp("aab", "aaa", 3) << endl; cout << strLen("") << endl; cout << strLen(str1) << endl; fadd = strStr(str1, "jkl"); cout << fadd << endl; fadd = strStr(str1, "bbb"); if (!fadd) cout << "Not found" << endl; strCpy(str2, "John "); strCat(str2, "Doe"); cout << str2 << endl; return 0;

cstring.h namespace sdds{ // Copies the srouce character string into the destination void strCpy(char* des, const char* src); // Copies the source character string into the destination upto "len" // characters. The destination will be null terminated only if the number // of the characters copied is less than "len" void strnCpy(char* des, const char* src, int len); // Compares two C-strings // returns 0 i thare the same // return > 0 if s1 > s2 // return < 0 if s1 < s2 int strCmp(const char* s1, const char* s2); // returns 0 i thare the same // return > 0 if s1 > s2 // return < 0 if s1 < s2 int strnCmp(const char* s1, const char* s2, int len); // returns the lenght of the C-string in characters int strLen(const char* s); // returns the address of first occurance of "str2" in "str1" // returns nullptr if no match is found const char* strStr(const char* str1, const char* str2); // Concantinates "src" C-string to the end of "des" void strCat(char* des, const char* src); } }

Requirement: create the cstring.cpp to get the following output:

abcdefghijklmnopqrstuvwxyz @@cdefghijklmnopqrstuvwxyz @@@defghijklmnopqrstuvwxyz @@@ 1 0 1 0 26 jklmnopqrstuvwxyz Not found John Doe

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