⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wb1.c

📁 该套软件用于提取王码98(或者其他版本)的五笔数据
💻 C
字号:
#include           <stdio.h>
#include           <stdlib.h>
#include           <float.h>
#include           <graphics.h>
#include           <math.h>
#include           <conio.h>
#include           <string.h>

#define            NG 			1
#define            OK 			0
#define            BCD          unsigned char
#define            CHR          unsigned char
#define            INT          unsigned int
#define 		   PTR			long


FILE *stream_father;
FILE *stream_son;
FILE *stream_sonx;

void make_wbzx(void);

void main(void)
{
	make_wbzx();
}

/*提取出一个汉字对应一个编码或者
两个汉字对应一个编码的记录*/

/****************************************
winwb98.txt==>wb98.ttt
winwb98.txt:
	1 chinese			:1 or 2 code
	2 or more chinese   :1 or 2 code
wb98.ttt:
	1 chinese			:1 code	(standard)
	2 chinese			:1 code (combination)
****************************************/
void make_wbzx(void)
{
	CHR buf[256];
	CHR	code1[5];
	CHR	code2[5];
	CHR	hz1[3];
	CHR	hz2[3];

	CHR a,i;
	CHR dhz_flag,dcd_flag;
	CHR *ptr;
	CHR *p;
	long r;

	CHR	tmp[20];


	hz1[2]='\0';
	hz2[2]='\0';
	code1[4]='\0';
	code2[4]='\0';

	stream_father = fopen("winwb98.txt","rt");	/*text*/
	if(stream_father ==NULL)
	{
		printf("Error: winwb98.txt not find!\n");
		return;
	}

	stream_sonx= fopen("winwb98.ttt","wt");
	if(stream_sonx==NULL)
	{
		printf("Error: winwb98.ttt not creat ! \n");
		return;
	}

	/*头部描述去掉*/

	for(i=0;i<12;i++)
	{
		fgets(buf,200,stream_father);		/*skip head*/
	}

	while (!feof(stream_father))
	{
		dhz_flag=0;
		fgets(buf,200,stream_father);
		hz1[0]=buf[0];
		hz1[1]=buf[1];
		if(buf[2]>0xa1)					/*两个或者多个汉字对应一个编码*/
		{
			dhz_flag=1;						/*2 hz*/
			hz2[0]=buf[2];
			hz2[1]=buf[3];
			if(buf[4]>0xa1)	continue;	/*多个,则skip*/
			strcpy(tmp,&buf[4]);		/**/
		}
		else
		{
			hz2[0]=' ';
			hz2[1]=' ';
			strcpy(tmp,&buf[2]);		/*code files*/
		}

		dcd_flag=0;

		ptr=strstr(tmp," ");
		if (ptr == NULL)			/*only 1 code*/
		{
			p=tmp;
			for(i=0;i<4;i++)
			{
				a=*p++;
				if(a=='\n') break;
				code1[i]=a;
			}
			for(;i<4;i++)		code1[i]=' ';
			for(i=0;i<4;i++)	code2[i]=' ';
		}
		else						/*对应多个编码(MAX.2)情况*/
		{
			dcd_flag=1;
			p=tmp;
			i=0;
			for(p=tmp;p<ptr;p++)
			{
				code1[i++]=*p;
			}
			for(;i<4;i++)	code1[i]=' ';

			strcpy(tmp,ptr+1);
			i=0;
			for(i=0;i<4;i++)
			{
				if(tmp[i]!='\n')	code2[i]=tmp[i];
				else				break;
			}
			for(;i<4;i++)	code2[i]=' ';
		}
//		printf("%s%s %s %s\n",hz1,hz2,code1,code2);

		if(dhz_flag==1)
		{
			if(dcd_flag==1)
			{
				fprintf(stream_sonx,"%s%s%s\n",hz1,hz2,code1);
				fprintf(stream_sonx,"%s%s%s\n",hz1,hz2,code2);
			}
			else
			{
				fprintf(stream_sonx,"%s%s%s\n",hz1,hz2,code1);
			}
		}
		else
		{
			if(dcd_flag==1)
			{
				fprintf(stream_sonx,"%s%s\n",hz1,code1);
				fprintf(stream_sonx,"%s%s\n",hz1,code2);
			}
			else
			{
				fprintf(stream_sonx,"%s%s\n",hz1,code1);
			}
		}

	}
	fclose(stream_sonx);
	fclose(stream_father);
	printf("OK\n");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -