Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions