testing strings to see if they contain certain combos. Instructions were to check last 2 characters to see if word ended in es and check substring to see if began yan....just remembered its supposed to be case insensitive...there isn't ignoreCase in c++ right? help?
/*Joseph Paigo
CISS 290
ex 3-10
This will compare strings
two ways, by charater and
by substring*/
#include<iostream>
#include<string>
using namespace std;
void main()
{
int i, j,k;
string str[3];
for (i = 0; i < 3; i++)
{
cout << "Enter a string: " << endl;
getline(cin, str[i], '\n' );
}
for (j = 0; j < 3; j++)
{
k = str[j].length();
if (str[j][k - 1] == 's' && str[j][k - 2] == 'e')
cout << str[j] <<"\n"<< endl;
if (str[j].substr(0, 3) == "yan")
cout << str[j]<<"\n"<<endl;
}
}
NOTE: for whatever reason he wants void main
this may depend a bit on your data. if you suspect most of the time the strings match exactly, you might want to do a normal compare and if that fails, then check caseless as above. this does more work when they are not exact, and less work when they are, so it may or may not help.