CodeMonkey that is correct to a certain extent, but it does not correctly answer the entire question. The question as if string one starts with string two. Although that does give a relatively decent answer. I dont know why not just get a substring of string1 as the length of string2, and compare string1.substr(0, string2.length()) == string2. Then again that may be incorrect.
it does work. here ya go. simple as hell really.
string one, two;
cout << "Enter string1: ";
cout << "Enter string2: ";
cout << '\n' << endl;
if ( two.length() < one.length() && one.substr(0, two.length()).compare(two) == 0 )
cout << "String 1 starts with string 2." << endl;
cout << "String 1 does not start with string 2." << endl;
if ( one.length() < two.length() && two.substr(0, one.length()).compare(one) == 0 )
cout << "String 2 starts with string 1." << endl;
cout << "String 2 does not start with string 1." << endl;