Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ String Compare

Name: Herpy McDerperson 2011-12-11 13:59

What the flying fuck is wrong with my C++ string compare?


//Stem word
string stemWord(string word)
{
    const int word_len = word.length();
    string stems[4] = {"ing","ed","er","s"};
    string temp = "";
    bool isStem;

    if (word_len > 4)
    {
        for (int i = 0; i < 4 || isStem == false; i++)
        {
            if (word.compare(word_len - stems[i].length(), stems[i].length(), stems[i]) == 0)
            {
                for (int x = 0; x < diff; x++)
                {
                    temp[x] += word[x];
                }

                word = temp;
            }      
        }
    }

    return word;
}

The word I'm sending to the is "testing," and this method is supposed to remove the stem (eg. "ing") and return the resulting stemmed word.

According to the MSDN's shitty "still, blahblah.." example (http://www.cplusplus.com/reference/string/string/compare/) this should work perfectly fine.

Name: Anonymous 2011-12-11 15:21

>>12
Your identation style is shit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List