建立小型汉字库的方法
源程序如下:
/建立汉字库程序/
#include"stdlib.h"
#include"stdio.h"
#include"fcntl.h"
#include"graphics.h"
char buffer[32];
FILEfp,fpl;
intxl,x2,i,f=0;
unsigned charhz,str[40];longhs;
main()
{
intdriver=VGA,mode=2;
initgraph(&driver,&mode,"");
fp=fopen("c:\\213
\\hzk16","rb");
/*打开字库文件/
if(fp==NULL){print f("could not open hzk16!");exit(1);}
while(1){
fpl=fopen("xhzk","ab");
/打开小型汉字库/
printf("\n请输入汉字[Q]退出!");
hz=str;
scanf("%s",hz);
if(str[0]=='Q')break;
while((i=hz++)!=0){
if(i〉0xal)
if(f==0){
xl=(i0xal)&0x07f;
f=1;}
else{
x2=(i0xal)&0x07f;
f=0;
hs=(xl_23)94321+(x223)321;
/字模在字库中地址/fseek(fp,hs,SEEK___SET);/确定指针位置/
fread(buffer,32,1,fp);
/将数据读入内存/
fwrite(buffer,32,1,fpl);
/写数据到新字库/
}}
fclose(fpl);}
fclose(fp);
}