Implementation of the dictionary class, C/C++ Programming

Implementation of the Dictionary class:

int Dictionary::find_word(char *s)

{

   char word[81];

   for (int i = 0; i < nwords; ++i)

      if (stricmp(words[i].get_word(word),s) == 0)

         return i;

 

   return -1;

}

 

void Dictionary::add_def(char *word, char **def)

{

   if (nwords < Maxwords)

   {

      words[nwords].put_word(word);

      while (*def != 0)

         words[nwords].add_meaning(*def++);

      ++nwords;

   }

}

 

int Dictionary::get_def(char *word, char **def)

{

   char meaning[81];

   int nw = 0;

   int word_idx = find_word(word);

   if (word_idx >= 0)

   {

      while (words[word_idx].get_meaning(nw,meaning) != 0)

      {

         def[nw] = new char[strlen(meaning)+1];

         strcpy(def[nw++],meaning);

      }

      def[nw] = 0;

   }

 

   return nw;

}

 

Posted Date: 10/18/2012 6:44:20 AM | Location : United States







Related Discussions:- Implementation of the dictionary class, Assignment Help, Ask Question on Implementation of the dictionary class, Get Answer, Expert's Help, Implementation of the dictionary class Discussions

Write discussion on Implementation of the dictionary class
Your posts are moderated
Related Questions
A body which has three forces acting on it is in equilibrium. One force is 3N to the North and the other is 4N to the west. What us the magnitude and direction of the third force?

You must write a program that can both decrypt and encrypt a single word that is entered by the user. The initial choice of encryption and decryption is left up to the user. Addi

Description - The TR-069 CPE WAN Management Protocol (CWMP) is a protocol that was created by the Broadband Forum (formally the DSL Forum) which sets out a common method for CPE de

Explain about the Character Constants in c language? The character constant is a single alphabet and a single digit or a single special symbol enclosed within a pair of single

An experiment succeeds twice as often as it fails. Find the chance that in the next six trials there will be at least four successes.

removing jewel from a necklace

SquareMaze The SquareMaze class should be declared and defined in maze.h and maze.cpp, respectively. Each SquareMaze object will represent a randomly-generated square maze and its

Member Functions of a Class A member function of the class is similar as an ordinary function. Its declaration in a class template must explain its return value as well as the

full coding for lcm in c++

Define External Storage Class - computer programming? When a variable is declared outside a function the storage is permanently assigned to it and its storage class is 'extern'