硬盘扇区读写技术-修复硬盘与恢复文件随书源代码
源代码在线查看: jian-h.c
//********************************************
//文件名:JIAN-H.C
//功能:建立汉字库头文件
//********************************************
#include //1.
#include //2.
void main() //3.
{ //4.
unsigned char *str="输入出需要查找的文件名" //5.定义字符串
"已经存在继续吗没有到柱面磁头扇区编号获得" //6.
"帮助程序使用方法错误十六进制和或字符显示" //7.
"数据打开失败备份拷贝搬移写清零源字节总算术"//8.
"是否去盘辑按键退出建立多少大小上下一二个块"//9.
"复起始终止存储主引导每簇目录登记项分配表整"//10.
"余占扩展基" //11.
"ABCDEFGHIJKLMNOPQRST" //12.
"UVWXYZ1234567890,。!+-"//13.
":/.()?〖〗\"; //14.
unsigned k,l; //15.
unsigned char c; //16.
int i,j; //17.
int qu,wei; //18.定义区码和位码变量
long sp; //19.
FILE *fp,*hzlib; //20.
l=strlen(str); //21.取字符串长度
fp=fopen("hzku.h","w"); //22.以写方式打开头文件
fprintf(fp,"unsigned sb[%u]={\n",l/2); //23.将汉字个数写入一维数组
j=1; //24.
while(*str) //25.
{ //26.
k=*str+(*(str+1))*256; //27.取机内码两字节的正整数值
str=str+2; //28.指针移到下一个汉字
printf("%u\n",k); //29.显示汉字特征值
if(j fprintf(fp,"%u,",k); //31.将特征值写入头文件
else //32.
fprintf(fp,"%u};\n",k); //33.
if(j%8==0) //34.写入8个值换行
fprintf(fp,"\n"); //35.
j++; //36.
} //37.
str=str-l; //38.调整字符串指针
fprintf(fp,"unsigned buff[%u][32]={\n",l/2);//39.将汉字个数写入二维数组
hzlib=fopen("hzk16","rb"); //40.打开标准字库
j=1; //41.
while(*str) //42.
{ //43.
fprintf(fp,"{"); //44.
qu=*str-0xa0; //45.换算区码
wei=*(str+1)-0xa0; //46.换算位码
sp=(qu-1)*94+wei-1; //47.算位移值
sp*=32; //48.
fseek(hzlib,(long)sp,0); //49.移动文件指针到汉字处
for(i=1;i { //51.
c=fgetc(hzlib); //52.读取字模
fprintf(fp,"0x%x,",c); //53.将字模写入二维数组
if(i%8==0) //54.写入8个值换行
fprintf(fp,"\n"); //55.
} //56.
c=fgetc(hzlib); //57.
if(j fprintf(fp,"0x%x},\n\n",c); //59.
else //60.
fprintf(fp,"0x%x}\n",c); //61.
str=str+2; //62.指针移到下一个汉字
j++; //63.
} //64.
fprintf(fp,"};"); //65.
fclose(fp); //66.关闭文件
fclose(hzlib); //67.
} //68.