-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathDICTION.CPP
More file actions
44 lines (38 loc) · 943 Bytes
/
DICTION.CPP
File metadata and controls
44 lines (38 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 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;
}