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
C Program for FUNCTION OF MERGE #include conio.h> #include stdio.h> char cot(char a[],char b[]); void main() {           char a[50],b[50];           clrscr()

write an algorithm that reads a postive integer n and then finds and prints the sum of all integers between 1 and n (inclusive) that are disvisible by 7. please write this using c

Pointer Types Pointer holds the address of an object, permitting for the indirect manipulation of that object. They are used in creating linked data structures like lists, tree

can you tell me what is c#

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

#include stdio.h> #include conio.h> #include ctype.h> #include string.h>   void main() {           int i=0,j=0,length;           char a[30];           cl

Write a program to convert English units to metric (e.g., miles to kilometers, gallons to liters, etc.). Include a specification and a code design.

Reference Types The symbol "&" is interpreted as an address operator as well as AND operator. This operator is also used to declare a "reference variable". A reference is refer

Pls i only need help with program 2. #include #include using namespace std; int main() { int FilingStatus; cout cout cout cout cout cout

explain me for loop