#include <iostream>

#include <string.h>

#include <ctime>

#include <fstream>

#define MAX  33227

#include <string>

using namespace std;

class dict_word

{

public:

char *word;//英文单词指针

//char *chinese;//中文意思指针

};


//创建一个打开字典的函数

int open_dict(dict_word **word, const char * dict_filename)//读取字典文件中的内容放到堆内存中

{

//使用文件IO流打开字典文件,打开文件用于读

ifstream infile(dict_filename, ios::in | ios::binary);

FILE *fp = fopen(dict_filename, "r");

if (fp == NULL)

{

cerr << "open file error" << endl;

return 0;

}


/*if (!infile)

{

cerr << "file open error" << endl;

return -1;

}*/

//给字典类的指针分配内存出并清空(根据单词个数来分配内存)MAX是文件中的单词个数

*word = (dict_word*)malloc(sizeof(dict_word)*MAX);//固定分配MAX的内存*word是一个存放结构体指针的数组的首地址