List 2-3 英和辞書を検索するC++アプリケーション
1: #include "stdafx.h"
2: #include "stdio.h"
3: #include "string.h"
4:
5: #define TRUE 1
6: #define FALSE 0
7: #define FOUND TRUE
8: #define NotFOUND FALSE
9:
10: struct EJ_Dictionary {
11: char lpszEword_dic[10];
12: char lpszJword_dic[10];
13: } dic[] = {{"pen","ペン"}, {"pencil","鉛筆"},{"book","本"}};
14:
15: class CDictionary
16: {
17: private:
18: // 単語数
19: int m_nWord;
20: public:
21: CDictionary();
22: ~CDictionary(){ }
23: // 辞書検索関数
24: int LookupWord(char* lpstrEword, char* lpstrJword);
25: };
26:
27: CDictionary::CDictionary(){
28: // 辞書の個数を算出する
29: m_nWord = sizeof(dic)/sizeof(EJ_Dictionary);
30: }
31:
32: // 英和辞書を検索する
33: int CDictionary::LookupWord(char *lpszEword, char* lpszJword)
34: {
35: for(int i=0;iLookupWord(Eword, Jword))
62: printf("%s は %sです。\n",Eword,Jword);
63: else
64: printf("%s は見つかりません。\n",Eword);
65: // CDictionaryオブジェクトを破棄する
66: delete pDictionary;
67: return TRUE;
68: }