linux 下自编简易命令行字典解决方法

linux 下自编简易命令行字典
为了学习ubuntu,考虑到经常我们查过一个单词又忘了,而我常常不能联网,我自己制作了个ubuntu命令行下的字典,单词需要自己添加,主要是对文件的存取以及一些逻辑上的关系,拿出来跟大家分享了。QQ:2595532032
头文件struct.h
//Define the structs used in the programs 
//List to check if the word is in the dictionary 
//DictWord to cat the words 
#define  WORD_SIZE 36 
#define  PHONETIC_SIZE 36 
#define  BUFFER_SIZE  72 
#define  MEANING_SIZE 72 
typedef struct 

    char word[WORD_SIZE]; 
    int  node; 
}List; 
typedef struct 

    int  node; 
    char word[WORD_SIZE]; 
    char phonetic[PHONETIC_SIZE]; 
    char meaning[MEANING_SIZE]; 
}DictWord;
头文件dicthelp.h
#include<stdio.h> 
#include<string.h> 
#include<stdlib.h> 
#include"struct.h" 

//Create the dict files 
int CreateDict() 

FILE *fp; 
fp=fopen("DictList","ab"); 
if(fp==NULL) 
return 0; 
fclose(fp); 

fp=fopen("Meaning","ab"); 
if(fp==NULL) 
return 0; 
fclose(fp); 
return 1; 

//check and return the num of the words 
int count() 

FILE *fp; 
List list; 
int   i=0; 
fp=fopen("DictList","rb"); 
if(fp==NULL) 

return -1; 

while(!feof(fp)) 

if(fread(&list,sizeof(list),1,fp)==1) 
i++; 

fclose(fp); 
return i; 

//the help books 
int loadhelp() 

   FILE *fp; 
   char ch; 
   fp=fopen("help","r"); 
   if(fp==NULL) 
       return 0; 
   while(!feof(fp)) 
   { 
         ch=fgetc(fp); 
         printf("%c",ch); 
   } 
   fclose(fp); 
   return 1; 


//to make sure if the wrod is already in the dict 
int  Travelsal(char *word) 

    FILE *fp; 
    List list; 
    list.node=0; 
    fp=fopen("DictList","rb"); 
    if(fp==NULL) 
        return 0; 
    while(!feof(fp)) 
      if(fread(&list,sizeof(list),1,fp)==1) 
      { 
           if(!strcmp(list.word,word))         //the word is already in the dict 
           {   
                fclose(fp); 
                return list.node; 
           } 
      } 
    fclose(fp); 
    list.node=0; 
    return list.node; 




------解决思路----------------------
英汉汉英字典C源代码 支持模糊查询,支持生成生词本。
http://download.****.net/detail/zhao4zhong1/4140015
------解决思路----------------------
厉害!学以致用!