TC; OPEN WATCOM学习记录之——字符模式下读取汉字库并显示汉字

cxdzxc 2012-06-17 12:34:46
#include <stdio.h>
#define draw '#'
#define x_origin 10
#define word_byte 2*16

void mygotoxy(int x,int y)
{
while(y--)
{printf("\n");}
while(x--)
{printf(" ");}
}

void hdz(int byte_dz)
{
int byte_bit_num=8;
while(byte_bit_num--)
{
if (byte_dz&0x80)
{
printf("%c",draw);
}
else
{
printf(" ");
}
byte_dz=byte_dz<<1;
}
}

int main(void)
{
int x=x_origin,y=5;
char buf[512],byte_dz,byte_bit_num=8;
int word_byte_i=0,show_i=0,word_origin=2*16*0,byte_dz_i=word_origin;
FILE *fp;
if (!(fp = fopen(".\\hzk16","rb")))
{
printf("open file fail\n");
}
fseek(fp,+word_byte*1500,SEEK_SET);
printf("ftell=0x%x\n",ftell(fp));
getch();

fread(buf,word_byte*5,1,fp);
while(show_i<word_byte*5)
{
while(word_byte_i++<word_byte)
{
printf("%x ",buf[show_i++]);
}
printf("\n");
word_byte_i=0;
}
getch();

system("cls");
mygotoxy(x,y);

while(byte_dz_i<(word_origin+word_byte))
{
byte_dz=buf[byte_dz_i++];
hdz(byte_dz);
byte_dz=buf[byte_dz_i++];
hdz(byte_dz);

printf("\n");
x=x_origin;
while(x--)
{printf(" ");}
}

getch();
fclose(fp);
return 0;
}

...全文
115 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxdzxc 2012-06-17
  • 打赏
  • 举报
回复
hdz形参应该用char类型:
下面是修改的:
#include <stdio.h>
#define draw '#'
#define x_origin 10
#define word_byte 2*16

void mygotoxy(int x,int y)
{
while(y--)
{printf("\n");}
while(x--)
{printf(" ");}
}

void hdz(char byte_dz)
{
int byte_bit_num=8;
while(byte_bit_num--)
{
if (byte_dz&0x80)
{
printf("%c",draw);
}
else
{
printf(" ");
}
byte_dz=byte_dz<<1;
}
}

int main(void)
{
int x=x_origin,y=5;
char buf[512],byte_dz,byte_bit_num=8;
int word_byte_i=0,show_i=0,word_origin=2*16*0,byte_dz_i=word_origin;
FILE *fp;
if (!(fp = fopen(".\\hzk16","rb")))
{
printf("open file fail\n");
}
fseek(fp,+word_byte*1500,SEEK_SET);
printf("ftell=0x%x\n",ftell(fp));
getch();

fread(buf,word_byte*5,1,fp);
while(show_i<word_byte*5)
{
while(word_byte_i++<word_byte)
{
printf("%x ",buf[show_i++]);
}
printf("\n");
word_byte_i=0;
}
getch();

system("cls");
mygotoxy(x,y);

while(byte_dz_i<(word_origin+word_byte))
{
byte_dz=buf[byte_dz_i++];
hdz(byte_dz);
byte_dz=buf[byte_dz_i++];
hdz(byte_dz);

printf("\n");
x=x_origin;
while(x--)
{printf(" ");}
}

getch();
fclose(fp);
return 0;
}

W170532934 2012-06-17
  • 打赏
  • 举报
回复
不错,学习了,不过这年代TC已经过时了。
Open Watcom manual 1.5.zip 官方PDF文档,已经添加目录标签,包含内容: cguide.pdf Open Watcom C/C++ User’s Guide cguideq.pdf Open Watcom C/C++ Compiler and Tools User’s Guide for QNX 3rd Edition clib.pdf Watcom C Library Reference Volume 1 clr.pdf Open Watcom C Language Reference cpplib.pdf Open Watcom C++ Class Library Reference cw.pdf Open Watcom CauseWay User’s Guide lguide.pdf Open Watcom Linker User’s Guide First Edition pguide.pdf Open Watcom C/C++ Programmer’s Guide tools.pdf Open Watcom C/C++ Tools User’s Guide First Edition wd.pdf Open Watcom Debugger User’s Guide vi.pdf Open Watcom Vi Editor Reference and User’s Guide Watcom使用简明 在Watcom安装目录下有三个程序目录 binnt/binp/binw,对应了 Windows NT/XP、OS2、MSDOS 和 Windows 3.x/9x等系统。当前系统为 Windows 7,使用 binnt 目录下的命令工具,各工具介绍: batserv.exe Batch Server wcc.exe C16 Optimizing Compiler cl.exe C/C++ CL Clone for 386 wcc386.exe C32 Optimizing Compiler ctags.exe CTAGS Utility wcl.exe C/C++16 Compile and Link Utility cvpack.exe CV4 Symbolic Compactor wcl386.exe C/C++32 Compile and Link Utility cvtres.exe C/C++ CVTRES Clone for 386 wd.exe Debugger dbginst.exe Debuger Driver Install wddespy.exe DDE Spy for Windows NT dmpobj.exe OMF Dump Utility wde.exe Dialog Editor for Windows NT drwatcom.exe Dr. Watcom for Windows NT wdis.exe Multi-processor Disassembler fcenable.exe Far Call Optimization Enabling wdw.exe Watcom Debuger ide.exe IDE wfc.exe FORTRAN 77/16 Optimizing Compiler lib.exe C/C++ LIB Clone for 386 wfc386.exe FORTRAN 77/32 Optimizing Compiler lib386.exe C/C++ LIB Clone for 386 wfl.exe F77/16 Compile and Link Utility link.exe C/C++ LINK Clone for 386 wfl386.exe F77/32 Compile and Link Utility link386.exe C/C++ LINK Clone for

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧