C语言高手快来救命啊!!

来源:百度知道 编辑:UC知道 时间:2024/05/12 12:01:43
下面的程序就是以UCDOS中16×16点阵字库HZK16作为提取汉字点
阵用的源字库,依据输入的汉字来确定其内码,从而从HZK16中提取汉字点阵。
#include “stdio.h”
#include “stdlib.h”
#include “io.h”
#include “conio.h”
#include “dos.h”
#include “fcntl.h”
#define NUM 20 /* 10个汉字,可以根据需要改变*/
struct
{
unsigned int code; /*汉字内码*/
unsigned char dot[32] /*汉字点阵*/
}lib[NUM];
union
{
unsigned char ch[2];
unsigned int i;
}ch_code;
FILE *fphz,*fpin,*fpout; /*三个文件指针*/
void drawdots(unsigned int incode,int num); /*读取点阵函数*/
main(int argc,char *argv[])
{
int num; /*汉字个数*/
int i,j;
if (argc<3)
{
printf(“Format must be:makepoint<fileinput><fileoutput>\n”);
exit(1);
}
fphz=fopen(“hzk16”, “rb”); /*打开汉字库HZK16*/
if(fphz==NULL)
{
printf(“Can’t open the chinese library hzk16.\n”);
exit(1);
}
fpin=fopen(argv[1], “rb”);
if(fpin==NULL)

argc是指参数的个数.
argv[]是一个字符串,是指参数
例如:
运行---->cmd---->就可以打开命令行窗口了.
然后用cd去到你的程式所在的目录.
然后输入test.exe c d再按回车.
test.exe是你的这个程式的名字.
c 和d就是参数了.
argc = 3;
argv[0]="test.ext"
argv[1]="c";
argv[2]="d"