#include #include #define WORDS_NUM 2001 /*最大数(レコード数)*/ #define WORD_SIZE 20 /*単語のサイズ*/ #define JIMI_SIZE 200 /*説明のサイズ*/ #define SBUF_SIZE 256 /*文字列バッファのサイズ*/ int main() { FILE *fp; char istr[SBUF_SIZE]; char word[WORDS_NUM][WORD_SIZE]; char jimi[WORDS_NUM][JIMI_SIZE]; char *tmp; int len, ct, i, dataerr; int wlenmax=0; int jlenmax=0; fp=fopen("ejdic2k.txt", "r"); if(fp==NULL){ printf("ファイル(ejdic2k.txt)を開けません\n"); return 1; } i=0; while(fgets(istr, sizeof(istr), fp)!=NULL) { dataerr=0; tmp=strtok(istr, "\t"); if(tmp!=NULL){ len=strlen(tmp); if (len>wlenmax) wlenmax=len; if(len>=WORD_SIZE) len=WORD_SIZE-1; strncpy(word[i], tmp, len); word[i][len]='\0'; } else{ dataerr=1; } tmp=strtok(NULL, "\n"); if(dataerr==0 && tmp!=NULL){ len=strlen(tmp); if (len>jlenmax) jlenmax=len; if(len>=JIMI_SIZE) len=JIMI_SIZE-1; strncpy(jimi[i], tmp, len); jimi[i][len]='\0'; } else{ dataerr=1; } if(dataerr==0) i++; if(i>=WORDS_NUM) break; } ct=i; fclose(fp); /* 読込んだデータの表示 */ for(i=0; i