Question: Need help with two C++ questions, please answer in basic understandable C++ code language, comments would be greatly appreciated since it could allow me to

Need help with two C++ questions, please answer in basic understandable C++ code language, comments would be greatly appreciated since it could allow me to better understand them. Thank you!

Greetings, our professor wants us to define char *strcopy( char *s1, const char *s2) and char *strcat(char *s1, const char *s2) in C++ language, he gave us an example of char *strlen here:

int mystrlen(const char pcString[])

{

int Length = 0;

while (pcString[Length] != '\0') Length++;

return Length;

}

However, he advised us to use pointer as a practice, and he posted another example below:

int mystrlen(const char *pcString)

/* Return the length of string pcString. */

{

const char *pcStringEnd = pcString;

while (*pcStringEnd != '\0') pcStringEnd++;

return pcStringEnd - pcString;

}

Both methods are fine (If you want to be extra helpful, you could write down both methods, that would be amazing for me to learn about it),please include comments! Thank you

Thank you for reading and helping!

*Sidenote: I doubt anyone here would need these, but our professor has told us the use of the function, just in case, I would post them below.

Definition of char *strcopy: copies the string s2 into the character array s1. The value of s1 is returned.

Definition of char*strcat: appends the string s2 to the end of character array s1. The first character from s2 overwrites the '\0' of s1. The value of s1 is returned.

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!