Close on the code tags. Note the / (slash) on the ending tag:
[code]
// code here
[/code]
You need to find "s" OR find "ing", not both. If you have "standing", you want to end up with "stand", right? So once you find, "ing" and delete it, make sure you do not test for "s".
string word = "standing";
bool foundIngPrefix = false;
// code
if (/* found "ing" prefix */)
{
// delete "ing" prefix.
foundIngPrefix = true;
}
if (!foundIngPrefix)
{
// test for and delete "s" if needed.
}
That'll solve the problem of accidentally finding both, but I think you have another problem. How about a word like "singer"? It has "ing" inside of it, but it doesn't END with it. rfind is going to find it and then you'll delete it. If the "ing" must be at the END, you'll need to add at least one more test before deleting.
Last edited by VernonDozier; Nov 5th, 2009 at 6:42 pm.
Reputation Points: 2614
Solved Threads: 687
Posting Expert
Offline 5,375 posts
since Jan 2008