Question: void append(char*& s, const char ch) { /* Appends the character ch to the c-string s. That is ch is added to the end of
void append(char*& s, const char ch) { /* Appends the character ch to the c-string s. That is ch is added to the end of s The parameter s is assumed to be a dynamic array (NOT a static one) */
}
void append(char*& s1, const char* s2) { /* Appends all the characters of s2 to s1 The parameter s1 is assumed to be a dynamic array (NOT a static one) */ }
//Test append function (appending a character to c-string) cout << endl; char* s2 = new char[1]; s2[0] = '\0'; cout << "Given the c-string " << s2 << endl; ch = 'a'; append(s2, ch); cout << "\tAppending " << ch << " results to " << s2 << endl; ch = 'b'; append(s2, ch); cout << "\tAppending " << ch << " results to " << s2 << endl;
//Test append function (appending a c-string to a c-string) cout << endl; cout << "Appending " << s1 << " to " << s2 << ", we get "; append(s2, s1); cout << s2 << endl;
can anyone deal this two append functions with C-string and without any built-in functions?
the ideal output will be following:
Given the c-string
Appending a results to a
Appending b results to ab
Appending massachussettes to ab, we get abmassachussettes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
