logo CodeStepByStep logo

marshallMathers

Language/Type: C++ string

Given the following variable declarations:

// index       0123456789012345678901234
string s1   = "Snoop Dogg";
string s2   = "Marshall 'Eminem' Mathers";
string s3   = s2.substr(18);
string book = "Art & Science of C++";

Give the results of the following expressions. Recall that the C++ string function find returns the special constant value string::npos when the substring is not found. Make sure to indicate a value of the proper type (e.g. strings in " " quotes, char in ' ' apostrophes).

s1.length()
s2.length()
s1[4]
s2[13]
s1.find("o")
s2.find("x")
s1.substr(6, 3)
s2.substr(21)
book.substr(6, 6)
toLowerCase(s3)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.