home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
-
- main()
- {
- FILE *dat,*idx;
- char buf[255];
- char *t;
- int n=255,j, buflen;
- long i,pos;
-
-
- dat = fopen("tdic.dic","r");
- idx = fopen("tdic.idx","wb");
- fwrite(&j,1,2,idx); /* number of index records */
- fgets(buf,n,dat);
- pos = strlen(buf);
- fgets(buf,n,dat);
- i = 1;
- do {
- buflen = strlen(buf);
- if ((i % 256) == 1) {
- for(j=0;buf[j] != '\t';j++);
- for(;j<25;j++)
- buf[j] = 0;
- strlwr(buf);
- fwrite(buf,1,25,idx);
- fwrite(&pos,1,4,idx);
- }
- pos += buflen;
- if ((t = fgets(buf,n,dat)) != NULL)
- i++;
- } while( t != NULL);
- j = i/256 + 1;
- fseek(idx, 0,SEEK_SET); /* rewrite number of index records */
- fwrite(&j,1,2,idx);
- fclose(idx);
- fclose(dat);
- }