| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4826 人关注过本帖
标题:[转帖]怎样在TC2.0中输入汉字输出汉字
只看楼主 加入收藏
zushuboderen
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2005-12-24
收藏
得分:0 
da大家怎么不用WIN-TC呢
支持中文的

冷静点............. 耐心点.............
2006-01-29 14:27
YF1042
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-1-30
收藏
得分:0 



     /********************汉字程序********************/

/********功能: 可以中英文混合显示^_^,读取汉字文本文件********/
#include <stdio.h>
#include <io.h>
#include <graphics.h>
#include <fcntl.h>
#include <dos.h>
#define CCLIB "C:\HZK16j" /*16*16点阵简体汉字库文件的路径*/

/***********主函数*************/
main()
{
int d,mode;
char *s="";
d=DETECT;mode=0;
initgraph(&d,&mode,"");
outhz(50,30,"请输入文件名:",2,14);
gotoxy(21,3);
scanf("%s",s);
Read_hz(50,50,600, s, 2);
getch();
closegraph();
}


/**********************显示汉字点阵***********************/
display(unsigned char *matrix,int x,int y,int color)
{
int i,j;
for(i=0; i < 16; ++i) {
for(j=0; j < 16; ++j)
if (matrix[i+i]&(1<<(7-j)))
putpixel(x+j,y,color);
for(j = 0; j < 8;++j)
if(matrix[i+i+1]&(1<<(7-j)))
putpixel(x+j+8,y,color);
y++;
}
}

/********************输出汉字函数******************************/
outhz(int col,int row,char *s,int z_color,int e_color)
{ int handle;
unsigned char English[2]=" \0";
unsigned char *printE=English;
unsigned qh,wh;
unsigned long offset;
unsigned char *hz,hzm[32];
handle= open(CCLIB,O_RDONLY|O_BINARY);
if(handle== -1) {
printf("Can't open the cclib!");
exit(-1);
}
hz=s;
while(*hz){
if(*hz< 128)
{ *printE=*hz; setcolor(e_color);
outtextxy(col, row+4, printE);
hz++; col=col+8; }
else
{ qh=*hz-0xa0;
wh=*(hz+1)-0xa0;
offset=(94*(qh-1)+(wh-1))*32l;
lseek(handle,offset,SEEK_SET);
read(handle,hzm,32);
display(hzm,col,row,z_color);
col += 16;
hz += 2;
}
}
close(handle);
}


/***********读取汉字文本文本(*.txt)函数,能显示中文标点符号(汉字文本文件中不能有字母或英文标点符号)**************/
Read_hz(int x, int y, int m, char *filename,int textcolor)
{
FILE *HzText;
char *Hz_str;
int size= 2*((m-x)/16)+1; /*计算每行可以显示的字数*/
int line= 1;
if((HzText=fopen(filename,"rt"))== NULL)
{ printf("Open file error!");
getch(); exit(1);
}
else
{ rewind(HzText);
while(!feof(HzText))
{
Hz_str= (char *)malloc(size);
if(Hz_str==NULL) { closegraph(); exit(1);}
fgets(Hz_str,size,HzText); /**取出一个汉字字符串**/
outhz(x,y+20*line,Hz_str,textcolor,textcolor); /**输出一个汉字字符串**/
free(Hz_str);
line++;
}
}
fclose(HzText);
}


2006-02-08 01:53
gongcd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-19
收藏
得分:0 
楼上程序运行错误

海纳百川,有容乃大.地载万物,无私则宽. 欢迎光临本人网站http://lll.
2006-02-08 11:42
阿毅
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-9-9
收藏
得分:0 

那里有中文版的win-tc啊,大家说一个把,多谢!

2006-09-09 22:09
快速回复:[转帖]怎样在TC2.0中输入汉字输出汉字
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011782 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved