c语言编程中怎么打汉字,c语言编程中,怎么打汉字啊??我是新手啊~~
該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓
N久以有寫的,圖形模式下顯示中文的程序,需要ucdos下ASC16,HZK16兩個(gè)字庫文件的支持。
里面的?printdot?函數(shù)為自己寫的打點(diǎn)函數(shù),非C標(biāo)準(zhǔn)的,用C標(biāo)準(zhǔn)函數(shù)代替一下。
參數(shù):transparency?是否有背景色
printword(int?x,int?y,char?*string,unsigned?char?color,unsigned?char?bgcolor,int?transparency)
{
FILE?*chinesestream,*englishstream;
int?charpoint=0;
unsigned?char?mask=1;
int?i,j,k;
unsigned?char?bit[32];
long?fpos;
unsigned?char?c;
mask=mask<<7;
/*讀入中文字庫*/
if((chinesestream=fopen("HZK16","rb"))==NULL)
{
printf("Open?hzk16?error!\n");
exit(0);
}
/*讀入英文字庫*/
if((englishstream=fopen("ASC16","rb"))==NULL)
{
printf("Open?asc16?error!\n");
exit(0);
}
while(string[charpoint]!='\0')
{
c=string[charpoint];
if(c<128)?/*要顯示的字為英文*/
{
fpos=16L*string[charpoint];
fseek(englishstream,?fpos,?SEEK_SET);
fread(bit,16,1,englishstream);
for(i=0;i<16;i++)
{
for(j=0;j<8;j++)
{
if(bit[i]&mask)
printdot(x+j+charpoint*8,y+i,color);
else
if(transparency)?printdot(x+j+charpoint*8,y+i,bgcolor);
bit[i]=bit[i]<<1;
}
}
charpoint++;
}
else?/*要顯示的字為中文*/
{
fpos=32L*(((unsigned?char)string[charpoint]-161)*94+((unsigned?char)string[charpoint+1]-161));
fseek(chinesestream,?fpos,?SEEK_SET);
fread(bit,32,1,chinesestream);
for(i=0;i<32;i=i+2)
{
for(k=0;k<2;k++)
for(j=0;j<8;j++)
{
if(bit[i+k]&mask)
printdot(x+j+charpoint*8+k*8,y+i/2,color);
else
if(transparency)?printdot(x+j+charpoint*8+k*8,y+i/2,bgcolor);
bit[i+k]=bit[i+k]<<1;
}
}
charpoint++;
charpoint++;
}
}
}
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的c语言编程中怎么打汉字,c语言编程中,怎么打汉字啊??我是新手啊~~的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 魔兽世界老滑头在哪钓
- 下一篇: c语言switch编写计算器,超级新手,