All pastes #932981 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-08 01:24 UTC
rendered paste body
int Segment::match(const char word[ ])
{
        int w_index = 0, c_index = 0, i = 0, match, ismatch = 0;

        match = strlen(word);
        printf("match  = %d\n\n", match);

        for(w_index; w_index < 9; w_index++) //loops through the words of the class
        {
                if(word_class[w_index][c_index] == word[i])
                {
                        ismatch++;
                        c_index++;
                        while(word[i] != '\0' && match != 0)
                        {
                                if(word_class[w_index][c_index] == word[i]) //character match
                                {
                                        ismatch++;
                                        c_index++;
                                        i++;
                                }
                                else if(word_class[w_index][c_index] != word[i])
                                        match = 0;
                        }
                        printf("***match = %d *** ismatch = %d\n\n", match, ismatch);
                        if(match == ismatch)
                                return w_index;
                        else
                                match = 0;
                }
        }
        return -1;
}