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 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


Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Q: When should you employ multiple inheritance? A:There  are  three  acceptable  answers:-  "Rarely," "Never," and  "while  the  problem  domain cannot be modeled accurately any

Explain about the strategies of implementation of the statecharts, Database Management System?

In this project, you will write a software for the Registrar's office of a university called YouOIT to maintain information about students and courses at the university. The reg

can we use const data member in static. member function with example.

Define Storage Classes of c program - computer programming? Each variable and function in C language has two attributes that are type and storage class. If storage class of a v

Define Character Input and Output with Files? This is done by using equivalents of putchar and getchar which are called putc and getc. Each one takes an extra argument which id

What is Virtual Destructor? Describe it.