My asssignmet is:
Input three strings into an array of strings. First, use a function to find the length for the end comparisons, then again compare the last two characters separately. Second, use a string function to take a sub-string of the first three characters for the beginning comparison all at once.
{
string stringarray[3] = {"yankee", "yes", "word"};
for (int x = 0; x < 3; x++)
string substringend1 = stringarray.substr(stringarray.length(stringarray[x]) - 2, stringarray.length(stringarray[x]));
string substringend2 = stringarray.substr(stringarray.length(stringarray[x]) - 1, stringarray.length(stringarray[x]));
string substringstart = stringarray.substr(0, 3);
if (substringend1 == "e" && substringend2 == "s" || substringstart == "yan") {
for (int y = 0; y < 3; y++)
cout << stringarray[y];
}
}
I know Im an idiot and this is a bad question format and whatever but I need help