⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diction.cpp

📁 c compiler with added projects...
💻 CPP
字号:
// Borland C++ - (C) Copyright 1991 by Borland International

// diction.cpp:   Implementation of the Dictionary class
// from Hands-on C++
#include "diction.h"

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -