LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 443|回复: 1

LINUX下汉字显示问题

[复制链接]
发表于 2004-5-12 16:55:16 | 显示全部楼层 |阅读模式
我将在DOS下用TC编译的程序用到GCC下编译出现了不少的错误.
程序如下:
/*******        crtlib.c     create cclib  *****/

#include <stdio.h>

#include <string.h>

#include <math.h>



FILE *fp;

char fname[30];



main()

{



  char choice,zkch[1];



  while(1){

  clrscr();

  printf("\n                       create cclib program");

  printf("\n\n                          the name of is");

  printf("\n\n                             cclib.16");

  printf("\n                         cclib.24*(k,s,f,h)");

  printf("\n");

  printf("\n          --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--");

  printf("\n");

  printf("\n                             0 : exit");

  printf("\n                             1 : hzk16");

  printf("\n                             2 : hzk24");

  printf("\n                        please choice(0,1,2) : ");

  choice=getche();



  if(choice=='0') exit(0);

  if(choice=='2'){

         printf("\n\n                       your hzk type(k,s,f,h) : ");

         zkch[0]=getche();zkch[1]='\0';

         if((zkch[0]!='s')&&(zkch[0]!='f')&&(zkch[0]!='k')&&(zkch[0]!='h'))

         {

           printf("\n\n choice error!!\n\n press any key to continue.....");

           getch();continue;

         }

         }

  else if(choice!='1')

    {  printf("\n\n choice error!!\n\n press any key to continue.....");

      getch();continue;

    }



  printf("\n\n          -**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-**-");

  printf("\n\n                          input hz text name : ");

  gets(fname);

  if ((fp=fopen(fname,"r"))==NULL){                                             /* r 为只读打开一个文本文件 */

   printf("\n can't open %s",fname);

   printf("\n press any key to continue....");

   getch();continue;}



  if(choice=='1'){

   printf("\ncclib has %3d chinces\n ",crt16());

   printf(" OK !    press any key to continue");getch();continue;

   }

  if(choice=='2'){

   printf("\n cclib has %3d chinces\n ",crt24(zkch));

   printf(" OK !    press any key to continue");getch();continue;

   }

  }

}



int crt16()

{

  FILE *fpzk,*fplib;

  unsigned char ch1,ch2;

  unsigned char s[32];

  unsigned int gb,i=0,addr=0;

  long p,x,y;

  int ch0;

  char zkn[]="hzk16";

  char cclibn[]="cclib.16";



  if ((fpzk=fopen(zkn,"rb"))==NULL){

      printf("\n\n can't open %s",zkn,"\n press any key to continue....");

      getch();return(0);}

  if ((fplib=fopen(cclibn,"wb+"))==NULL) {

      printf("\n\n can't open %s",cclibn,"\n press any key to continue....");

      getch();return(0);}

  printf("\n         cclib is creating..........");

/*  fseek(fplib,0,0);

  fwrite(&addr,2,1,fplib);*/

  addr=2;

  while(1){

   ch1=getc(fp);

   if(ch1==10)

   continue;

   ch2=getc(fp);

   ch0=ch1;

   if (ch0==255)break;

   gb=(ch1-160)*100+ch2-160;

   x=gb/100;y=gb%100;

   p=((x-1)*94+y-1)*32;



   fseek(fpzk,p,SEEK_SET);

   if(fread(&s,32,1,fpzk)==NULL)

    { printf("\nhzk may be drimage !");exit(0);}

   fseek(fplib,addr,SEEK_SET);

   fwrite(&ch1,1,1,fplib);

   fwrite(&ch2,1,1,fplib);

   fwrite(&s,32,1,fplib);

   addr=addr+34;

   i++;

   }

   fseek(fplib,0,0);

   fwrite(&i,2,1,fplib);

   fclose(fpzk);fclose(fplib);fclose(fp);

   return(i);

}





int crt24(char tps[])

{

  FILE *fpzk,*fplib,*fpt;

  unsigned char ch1,ch2;

  unsigned char s[72];



  unsigned char ss[72];



  unsigned int gb,i=0,addr=0,ii=0;

  long p,x,y;

  int x1,j;

  unsigned char y1;

  int ch0;

  char zkn[40]="hzk24";

  char cclibn[]="cclib.24";



  strcat(zkn,tps);

  strcat(cclibn,tps);



  printf("aaaaaaaaa");



  if ((fpzk=fopen("hzk24k","rb"))==NULL){

    printf("\n\n can't open %s",zkn,"\npress any key to continue....");

    printf("\nasdfsadfklsafdkljasdflk");

    getch();return(0);}

  printf("bbbbbbbbb");



  if ((fpt=fopen("hzk24t.","rb"))==NULL){

    printf("\n\n can't open %s",fname,"\npress any key to continue....");

    getch();return(0);}

  if ((fplib=fopen(cclibn,"wb+"))==NULL){

    printf("\n\n can't open %s",fname,"\npress any key to continue....");

    getch();return(0);}



  printf("\n         cclib is creating..........");



/*  fseek(fplib,0,0);

  fwrite(&addr,2,1,fplib);*/



  addr=2;



  while(1){

   ch1=getc(fp); if(ch1==10)continue;

   ch2=getc(fp);

   ch0=ch1;

   if(ch0==255)break;

   gb=(ch1-160)*100+ch2-160;

   x=gb/100;y=gb%100;

   if(x>=16)

     {

      p=((x-16)*94+y-1)*72;

      fseek(fpzk,p,SEEK_SET);

      if(fread(&s,72,1,fpzk)==NULL) exit(0);

    }

    else{

      p=((x-1)*94+y-1)*72;

      fseek(fpt,p,SEEK_SET);

      if(fread(&s,72,1,fpt)==NULL) exit(0);

      }

   fseek(fplib,addr,SEEK_SET);



  for (ii=0;ii<72;ii++)

   {

     ss[ii]=0;

     x1=(ii/24)+(ii%3)*24;

     y1=(unsigned char)pow(2,(7-((ii%24)/3)));

/*     printf("\n%3d    %3d    %3d",i,x1,y1);getch();*/

     for (j=0;j<8;j++,x1=x1+3)

      if ((s[x1]&y1)!=0) ss[ii]=ss[ii]+(unsigned char)pow(2,(7-j));

   }



   for (ii=0;ii<72;ii++) s[ii]=ss[ii];



   fwrite(&ch1,1,1,fplib);

   fwrite(&ch2,1,1,fplib);

   fwrite(&s,72,1,fplib);

   addr=addr+74;

   i++;

   }



   fseek(fplib,0,0);

   fwrite(&i,2,1,fplib);

   fclose(fpzk);fclose(fp);fclose(fplib);fclose(fpt);

   return(i);

}

出现的错误如下:
crtlib.cpp: In function `int main()':
crtlib.cpp:16: `clrscr' undeclared (first use this function)
crtlib.cpp:16: (Each undeclared identifier is reported only once for each
   function it appears in.)
crtlib.cpp:28: `getche' undeclared (first use this function)
crtlib.cpp:30: `exit' undeclared (first use this function)
crtlib.cpp:37: `getch' undeclared (first use this function)
crtlib.cpp:54: `crt16' undeclared (first use this function)
crtlib.cpp:58: `crt24' undeclared (first use this function)
crtlib.cpp: In function `int crt16()':
crtlib.cpp:65: `int crt16()' used prior to declaration
crtlib.cpp:97: warning: NULL used in arithmetic
crtlib.cpp: In function `int crt24(char*)':
crtlib.cpp:114: `int crt24(char*)' used prior to declaration
crtlib.cpp:165: warning: NULL used in arithmetic
crtlib.cpp:170: warning: NULL used in arithmetic

请问,参数的设置在LINUX下应该怎么设置?还有,要以16*16或24*24来显示汉字的话又应该如何定义?文件为空的话在 LINUX下应该如何表示!? 请达人解决下我上面出现的错误吧~~谢谢
发表于 2004-5-12 18:09:18 | 显示全部楼层
看的累啊,下次用code显示
1: gcc -o crtlib crtlib.c成功生成crtlib
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表