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

Assignment Help:

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;

}

 


Related Discussions:- Implementation of the dictionary class

#task1, program for factorial

program for factorial

Should my class declare a friend function or member function, A: Use a memb...

A: Use a member while you can and a friend when you need to. Sometimes friends are better syntactically (e.g., in class Fred, friend functions let the Fred parameter to be secon

Padovan string, write a javaprogram to solve padovan string using java? ...

write a javaprogram to solve padovan string using java? program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring;

Padovan string , .write a program that counts the number of occurrences of ...

.write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

Coding Arena A B C D E F G, Damjibhai and Sham...

Damjibhai and Shamjibhai are two jeweler friends. They decide to play a simple game. The game comprises of removing the jewels for polishing, turn by turn. Once a jewel is removed

.Change to palindrome, A palindrome is a string that reads the same from bo...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Stone game, how to write a c program for stone game

how to write a c program for stone game

201 it, overload assignment opertor to assign the data of one object to ant...

overload assignment opertor to assign the data of one object to anthor

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd