Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** CS 150 C-Strings Follow the instructions on your handout to complete the requested function. You may not use ANY library functions or include any

image text in transcribed

/**

CS 150 C-Strings

Follow the instructions on your handout to complete the

requested function. You may not use ANY library functions

or include any headers, except for for size_t.

*/

#include // size_t for sizes and indexes

///////////////// WRITE YOUR FUNCTION BELOW THIS LINE ///////////////////////

///////////////// WRITE YOUR FUNCTION ABOVE THIS LINE ///////////////////////

// These are OK after the function

#include

#include

using namespace std;

void CHECK(const char*, char, const string&);

void studentTests()

{

cout

cout

CHECK("Aardvark", 'a', "ardvark");

CHECK("Aardvark", 'k', "k");

CHECK("Aardvark", 'A', "Aardvark");

CHECK("Aardvark", 'K', "nullptr");

cout

cout

}

int main()

{

studentTests();

}

#include

void CHECK(const char * s, char c, const string& expected)

{

char data[1024];

strcpy(data, s);

string msg = "myStrChr(\"" + string(data) + "\", '" + c + "')";

auto p = myStrChr(data, c);

string actual = (p ? string(p) : "nullptr");

if (expected == actual)

cout OK"

else

cout , found "

}

10THE MYSTRNCAT FUNCTION Write the function myStrNCat(). The function has three parameters: a char * s1, a const char * s2, and an size_ t max, which represents the maximum size of the s1 buffer. Append the characters in s2 to the end of s1. Make sure you have only one 'e at the end of the combined characters. Don't go beyond the end of the buffer you are asked to copy to. The function returns a pointer to the first character in s1

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions