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
How do you access the values within an array? - Arrays comprise a number of elements, which depends on the size you assigned it during variable declaration. - Every element

I need Computer application/program. Project Description:                                                                I want a project done. It is a computer desktop appli

how to write c++ for function f(x)= 2x^3 -x^2 +10

Program1: Write a program to find the factorial of a given number. The input is user given. Final output is printed out on to the screen. Program2: Write a program to gene

It is standard on functions to provide some indication that the function has succeeded in its operation. Consider the Scanf function:     scanf("%d",&number1);   If the functio

Differentiate between functions getch () and getche (). - Both functions accept a character input value from user. - When getch () is used, key that was pressed won't appear

(RationalNumber Class) A rational number is a number that can be represented as the quotient of two integers. For example, 1/3, 5/7, 7/2, and so forth are rational numbers (By 2/1

Write a program to process bank accounts. Create a base class named Account and two derived classes named Savings and Checking. In the base class, use an int AccountNum and a dou

I''m trying to write a function that prints the substring if it is found in the string, and after it prints it deletes it from the string so i could print the next substring if it

Programming Assignment #3: Vehicle Track Performance Tests Purpose: The purpose of this programming assignment is to give the student experience in using functions, arrays, and str