string method definition

Hey this is my first post and im trying to figure out how to complete this method definition if someone could help that would be great:



MyString::MyString(const char* s)

This constructor for the MyString class should copy the C string s into the string array. If the length of s is greater than the string capacity, you should only copy a number of characters equal to the string capacity (we don't want to overflow the string array). You need to make sure that the C string you end up with in the string array actually ends with a null character. The string size should be set to the lesser of the length of s or the string capacity.

this is what i have so far:

MyString::MyString(const char* s)
{

strcpy(array, s.c_str());

if (s > capacity)
{

}

i know what i want to say in the if statement i just dont know how to type it out
Look at strncpy(). Also, s does not have any member functions, so s.c_str() doesn't work.
Topic archived. No new replies allowed.