fails to write a function
void findsynonyry (const char synonymdictionary [20] [2] [31], INT Count, Const Char Word [31 ], char synonym [31]);
Input:
Synonymdictionary
– Dictionary of Synonyms
count
– Number of synonyms pairs
Word
– the word for which you need to choose a synonym
Output:
synonym
synonym; If the synonym is not found, an empty string is returned.
I tried to use the standard strstr
functions in the dictionary of the source word found but it is impossible to do so that it takes the synonym for this word
char const * words = null;
For (int i = 0; i & lt; Count & amp; & amp; Words == NULL; I ++) {
For (int j = 0; j & lt; 2 & amp; & amp; Words == NULL; j ++) {
For (int k = 0; k & lt; 32 & amp; & amp; Words == NULL; K ++) {
Words = STRSTR (& amp; synonymdictionary [i] [j] [k], word);
}
}
}
Answer 1, Authority 100%
Roughly, no error checks:
// We are looking for synonym
For (j = 0; J & LT; Count; j ++) {
if (STRCMP (Synonymdictionary [J], Word) == 0) {
STRNCPY (Synonym, Synonymdictionary [j], 31);
Return;
}
}
// not found - we return an empty string:
synonym [0] = '\ 0';
Return;