First, you need to build some kind of data structure, like say
Code:
struct wordpairs {
char *word;
int numAllowed;
char **allowedPairs;
};
Code:
char *pairsForFred[] = { "Wilma", "Pebbles" };
char *pairsForBarney[] = { "Betty", "BamBam" };
struct wordpairs wordlist[] = {
{ "Fred", 2, pairsForFred },
{ "Barney", 2, pairsForBarney }
}
Now you could go the other way, for each word, you have a list of words it CAN'T be matched with. Use whichever gives you the shorter lists.
Having generated the first word, you search for it in wordlist[i].word.
Then you search for your second word in wordlist[i].allowedPairs[j]
As for your comparison, strcmp() returns == 0 if they match, and != 0 if they don't.