Home>

fails to write a function Void FindSynonym (Const Char SynonymDictionary [20] [2] [31], INT Count, Const Char Word [31], Char Synonym [31]);

Input data: Synonymdictionary -Dictionary of Synonyms Count -Number of Couples Synonyms Word -the word for which you need to choose synonym Output: synonym -synonym; If the synonym is not found, an empty string is returned. I tried to use the standard strstr functions to find in the dictionary of the source word found but it does not work in any way so that it takes the synonym for this word

char const * Words= NULL;
for (int i= 0; i <
 Count &
&
 Words== NULL; I ++) {
    for (int j= 0; j <
 2 &
&
 Words== NULL; j ++) {
        for (int k= 0; k <
 32 &
&
 Words== NULL; K ++) {
            WORDS= STRSTR (&
synonymdictionary [i] [j] [k], word);
        }
    }
}
c
  • Answer # 1

    Roughly, without error checks:

    //We are looking for synonym
    for (j= 0; j <
    Count; j ++) {
        if (STRCMP (Synonymdictionary [J], Word)== 0) {
            STRNCPY (Synonym, Synonymdictionary [j], 31);
            Return;
        }
    }
    //not found -we return the empty string:
    synonym [0]= '\ 0';
    Return;
    
  • Answer # 2

    Roughly, without error checks:

    //We are looking for synonym
    for (j= 0; j <
    Count; j ++) {
        if (STRCMP (Synonymdictionary [J], Word)== 0) {
            STRNCPY (Synonym, Synonymdictionary [j], 31);
            Return;
        }
    }
    //not found -we return the empty string:
    synonym [0]= '\ 0';
    Return;