Home c implement and use a function that returns direct synonym for a given...

implement and use a function that returns direct synonym for a given word

Author

Date

Category

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;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions