| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2818 人关注过本帖
标题:Type mismatch in redeclaration of "myprintf! 求解答!
只看楼主 加入收藏
ymqq
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:141
专家分:143
注 册:2010-7-14
结帖率:73.33%
收藏
已结贴  问题点数:50 回复次数:2 
Type mismatch in redeclaration of "myprintf! 求解答!
以下函数(在 DOSbox BorlandC 3,0中) 结果 显示 “Type mismatch in redeclaration of "myprintf"” ,怎么解决啊?
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>
#include <bios.h>
#define HZKLOD   "f:\\hzk16"
#define BGILOD   "e:\\TCPP30H\\bgi"
#define ASCLOD   "f:\\asc16"

/*******数据结构**********/



/****鼠标函数******/
void mousestr()
{
 union REGS in;
 in.x.ax=0;
 int86(0x33,&in,&in);
 if(in.x.ax==0)
  myprintf(40,200,"鼠标初始化错误!",RED);
}
void mouseappear()
{
 union REGS in;
 in.x.ax=1;
 int86(0x33,&in,&in);
}
void mousehide()
{union REGS in;
 in.x.ax=2;
 it86(0x33,&in,&in);
}
void mousepos(int *x,int *y,int *m)
{
 union REGS in;
 in.x.ax=3;
 int86(0x33,&in,&in);
 x=in.x.cx;
 y=in.x.dx;
 m=in.x.bx;
}
void setmoupos(int x,int y)
{
 union REGS in;
 in.x.cx=x;
 in.x.dx=y;
 int86(0x33,&in,&in);
}
void setmosxarea(int minx,int maxx)
{
 union REGS in;
 in.x.cx=minx;
 in.x.dx=maxx;
 in.a.ax=7;
 int86(0x33,&in,&in);
}
void setmosyarea(int miny,int maxy)
{
 union REGS in;
 in.x.cx=miny;
 in.x.dx=maxy;
 int86(0x33,&in,&in);
}
int checkmouarea(in x1,int y1,int x2,int y2)
{
 int x,y,i;
 mousepos(&x,&y,&i);
 if(x<x1||x>x2||y<y1||y>y2) return 0;
 else if(!i) return 1;
      else   return  2;   
 
}


/*****自定义输出函数****/
void graphini()
{
 int gd=DETECT,gm;
 registerbgidriver(EGAVGA_driver);
 initgraph(&gd,&gm,BGILOD);

}
void myprintf(int x,int y,char *m,int color)
{
 FILE *fp,*fpa;
 int i,j,k;
 long int fpos; /*具体字在字库中的偏移量*/
if((fp=fopen(HZKLOD,"rb"))==NULL) /*打开16*16点阵汉字字库*/
        {
           printf("Cannot open  hzk16!press any key to quit!");
           getch();
           exit(0);}
if((fpa=fopen(ASCLOD,"rb"))==NULL) /*打开16*16点阵英文字库*/
               {
                  printf("Can't open asc16 !press any key to quit!");
                  getch();
                  exit(0);
                   }
 for(i=0;*(m+i)!='\0';i++)
 {
   if(*(m+i)<0)
   {

          unsigned char qh,wh,bitdata[32],bit[8]={128,64,32,16,8,4,2,1};
          int k,j;
          qh=*(m+i)-0xa0; /*汉字区位码*/
          wh=*(m+i+1)-0xa0;
          fpos=(94*(qh-1)+(wh-1))*32L ; /*获得字模在字库中的位置*/
          fseek(fp,fpos,SEEK_SET);
          fread(bitdata,32,1,fp); /*把该汉字字模读入到bitdata中*/
          for(k=0;k<16;k++)
                      for(j=0;j<8;j++) /*和bit[]与操作以后,在屏幕上画点*/
                         {
              if(bitdata[2*k]&bit[j]) putpixel(x+j,k+y,color);
              if(bitdata[2*k+1]&bit[j]) putpixel(x+8+j,k+y,color);
                          }
                         i++;
                        x+=16;

    }
     else
         {  char buffera[16];

           fpos=(*(m+i))*16;
           fseek(fpa,fpos,SEEK_SET);              /*****查找英文字符在ASC16文件中的位置******/
            fread(buffera,1,16,fpa);            /****读取英文字符在ASC16文件中的字段*******/
            for(k=0;k<16;k++)
                for(j=0;j<8;j++)
                    if(((buffera[k]>>(7-j))&0x1)!=NULL)
                        putpixel(j+x,k+y,color);           /**如果该位非空,则画点***********/
            x+=8;                                    /******屏幕光标偏移量***********************/
        }

    if(x>=getmaxx())
        {  y+=16;
           x=0; }
       }

   fclose(fp);      /*********关闭文件指针*********/
   fclose(fpa);      /*********关闭文件指针*********/
 }/******欢迎界面函数***********/
void welcome()
{
                                                 /*****暂未开发******/
}

/*****************功能函数****************/
void jiemian()
{
  setbkcolor(7);
  setcolor(WHITE);
  rectangle(5,5,634,474);
  line(5,24,639,24);
}
void function()
{
jiemian();

}

/*****************退出函数****************/
void thinkused()
{
}
/*****************主函数*****************/
void main()
{
 graphini();
 welcome();/******欢迎界面*******/
 function();/******功能函数****/
 thinkused();
 closegraph();
}
搜索更多相关主题的帖子: mismatch myprintf Type 解答 
2010-08-28 10:19
S_12s
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:110
专家分:670
注 册:2010-7-21
收藏
得分:35 
我改了一下,好像没错误,在TC下有很多警告:
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>
#include <bios.h>
#define HZKLOD   "f:\\hzk16"
#define BGILOD   "e:\\TCPP30H\\bgi"
#define ASCLOD   "f:\\asc16"

/*******Êý¾Ý½á¹¹**********/

void myprintf(int x,int y,char *m,int color)
{
FILE *fp,*fpa;
int i,j,k;
long int fpos; /*¾ßÌå×ÖÔÚ×Ö¿âÖеÄÆ«ÒÆÁ¿*/
if((fp=fopen(HZKLOD,"rb"))==NULL) /*´ò¿ª16*16µãÕóºº×Ö×Ö¿â*/
        {
           printf("Cannot open  hzk16!press any key to quit!");
           getch();
           exit(0);}
if((fpa=fopen(ASCLOD,"rb"))==NULL) /*´ò¿ª16*16µãÕóÓ¢ÎÄ×Ö¿â*/
               {
                  printf("Can't open asc16 !press any key to quit!");
                  getch();
                  exit(0);
                   }
for(i=0;*(m+i)!='\0';i++)
{
   if(*(m+i)<0)
   {

          unsigned char qh,wh,bitdata[32],bit[8]={128,64,32,16,8,4,2,1};
          int k,j;
          qh=*(m+i)-0xa0; /*ºº×ÖÇøλÂë*/
          wh=*(m+i+1)-0xa0;
          fpos=(94*(qh-1)+(wh-1))*32L ; /*»ñµÃ×ÖÄ£ÔÚ×Ö¿âÖеÄλÖÃ*/
          fseek(fp,fpos,SEEK_SET);
          fread(bitdata,32,1,fp); /*°Ñ¸Ãºº×Ö×ÖÄ£¶ÁÈëµ½bitdataÖÐ*/
          for(k=0;k<16;k++)
                      for(j=0;j<8;j++) /*ºÍbit[]Óë²Ù×÷ÒÔºó£¬ÔÚÆÁÄ»ÉÏ»­µã*/
                         {
              if(bitdata[2*k]&bit[j]) putpixel(x+j,k+y,color);
              if(bitdata[2*k+1]&bit[j]) putpixel(x+8+j,k+y,color);
                          }
                         i++;
                        x+=16;

    }
     else
         {  char buffera[16];

           fpos=(*(m+i))*16;
           fseek(fpa,fpos,SEEK_SET);              /*****²éÕÒÓ¢ÎÄ×Ö·ûÔÚASC16ÎļþÖеÄλÖÃ******/
            fread(buffera,1,16,fpa);            /****¶ÁÈ¡Ó¢ÎÄ×Ö·ûÔÚASC16ÎļþÖеÄ×Ö¶Î*******/
            for(k=0;k<16;k++)
                for(j=0;j<8;j++)
                    if(((buffera[k]>>(7-j))&0x1)!=NULL)
                        putpixel(j+x,k+y,color);           /**Èç¹û¸Ãλ·Ç¿Õ£¬Ôò»­µã***********/
            x+=8;                                    /******ÆÁÄ»¹â±êÆ«ÒÆÁ¿***********************/
        }

    if(x>=getmaxx())
        {  y+=16;
           x=0; }
       }

   fclose(fp);      /*********¹Ø±ÕÎļþÖ¸Õë*********/
   fclose(fpa);      /*********¹Ø±ÕÎļþÖ¸Õë*********/
}/******»¶Ó­½çÃ溯Êý***********/



/****Êó±êº¯Êý******/
void mousestr()
{
char a[]="mouse error!";
union REGS in;
in.x.ax=0;
int86(0x33,&in,&in);
if(in.x.ax==0)
  myprintf(40,200,a,1);
}



void mouseappear()
{
union REGS in;
in.x.ax=1;
int86(0x33,&in,&in);
}





void mousehide()
{union REGS in;
in.x.ax=2;
int86(0x33,&in,&in);
}





void mousepos(int *x,int *y,int *m)
{
union REGS in;
in.x.ax=3;
int86(0x33,&in,&in);
x=in.x.cx;
y=in.x.dx;
m=in.x.bx;
}




void setmoupos(int x,int y)
{
union REGS in;
in.x.cx=x;
in.x.dx=y;
int86(0x33,&in,&in);
}





void setmosxarea(int minx,int maxx)
{
union REGS in;
in.x.cx=minx;
in.x.dx=maxx;
in.x.ax=7;
int86(0x33,&in,&in);
}




void setmosyarea(int miny,int maxy)
{
union REGS in;
in.x.cx=miny;
in.x.dx=maxy;
int86(0x33,&in,&in);
}
int checkmouarea(int x1,int y1,int x2,int y2)
{
int x,y,i;
mousepos(&x,&y,&i);
if(x<x1||x>x2||y<y1||y>y2) return 0;
else if(!i) return 1;
      else   return  2;  


}


/*****×Ô¶¨ÒåÊä³öº¯Êý****/
void graphini()
{
int gd=DETECT,gm;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,BGILOD);

}










void welcome()
{
                                                 /*****ÔÝ먦·¢******/
}




/*****************¹¦Äܺ¯Êý****************/
void jiemian()
{
  setbkcolor(7);
  setcolor(WHITE);
  rectangle(5,5,634,474);
  line(5,24,639,24);
}




void function()
{
jiemian();

}




/*****************Í˳öº¯Êý****************/
void thinkused()
{
}




/*****************Ö÷º¯Êý*****************/
void main()
{
graphini();
welcome();/******»¶Ó­½çÃæ*******/
function();/******¹¦Äܺ¯Êý****/
thinkused();
closegraph();
}
但没结果……

[ 本帖最后由 S_12s 于 2010-8-28 11:17 编辑 ]
2010-08-28 11:15
ymqq
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:141
专家分:143
注 册:2010-7-14
收藏
得分:0 
是啊 ,好多 警告!我后来改了一下 发现可以了
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>
#include <bios.h>
#define HZKLOD   "f:\\hzk16"
#define BGILOD   "e:\\TCPP30H\\bgi"
#define ASCLOD   "f:\\asc16"

/*******数据结构**********/



/****鼠标函数******/
void mousestr()
{
union REGS in;
in.x.ax=0;
int86(0x33,&in,&in);
if(in.x.ax==0)
 /* myprintf(40,200,"鼠标初始化错误!",RED);*/ /*去掉这一行*/
}
void mouseappear()
{
union REGS in;
in.x.ax=1;
int86(0x33,&in,&in);
}
void mousehide()
{union REGS in;
in.x.ax=2;
it86(0x33,&in,&in);
}
void mousepos(int *x,int *y,int *m)
{
union REGS in;
in.x.ax=3;
int86(0x33,&in,&in);
x=in.x.cx;
y=in.x.dx;
m=in.x.bx;
}
void setmoupos(int x,int y)
{
union REGS in;
in.x.cx=x;
in.x.dx=y;
int86(0x33,&in,&in);
}
void setmosxarea(int minx,int maxx)
{
union REGS in;
in.x.cx=minx;
in.x.dx=maxx;
in.a.ax=7;
int86(0x33,&in,&in);
}
void setmosyarea(int miny,int maxy)
{
union REGS in;
in.x.cx=miny;
in.x.dx=maxy;
int86(0x33,&in,&in);
}
int checkmouarea(in x1,int y1,int x2,int y2)
{
int x,y,i;
mousepos(&x,&y,&i);
if(x<x1||x>x2||y<y1||y>y2) return 0;
else if(!i) return 1;
      else   return  2;   

}


/*****自定义输出函数****/
void graphini()
{
int gd=DETECT,gm;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,BGILOD);

}
void myprintf(int x,int y,char *m,int color)
{
FILE *fp,*fpa;
int i,j,k;
long int fpos; /*具体字在字库中的偏移量*/
if((fp=fopen(HZKLOD,"rb"))==NULL) /*打开16*16点阵汉字字库*/
        {
           printf("Cannot open  hzk16!press any key to quit!");
           getch();
           exit(0);}
if((fpa=fopen(ASCLOD,"rb"))==NULL) /*打开16*16点阵英文字库*/
               {
                  printf("Can't open asc16 !press any key to quit!");
                  getch();
                  exit(0);
                   }
for(i=0;*(m+i)!='\0';i++)
{
   if(*(m+i)<0)
   {

          unsigned char qh,wh,bitdata[32],bit[8]={128,64,32,16,8,4,2,1};
          int k,j;
          qh=*(m+i)-0xa0; /*汉字区位码*/
          wh=*(m+i+1)-0xa0;
          fpos=(94*(qh-1)+(wh-1))*32L ; /*获得字模在字库中的位置*/
          fseek(fp,fpos,SEEK_SET);
          fread(bitdata,32,1,fp); /*把该汉字字模读入到bitdata中*/
          for(k=0;k<16;k++)
                      for(j=0;j<8;j++) /*和bit[]与操作以后,在屏幕上画点*/
                         {
              if(bitdata[2*k]&bit[j]) putpixel(x+j,k+y,color);
              if(bitdata[2*k+1]&bit[j]) putpixel(x+8+j,k+y,color);
                          }
                         i++;
                        x+=16;

    }
     else
         {  char buffera[16];

           fpos=(*(m+i))*16;
           fseek(fpa,fpos,SEEK_SET);              /*****查找英文字符在ASC16文件中的位置******/
            fread(buffera,1,16,fpa);            /****读取英文字符在ASC16文件中的字段*******/
            for(k=0;k<16;k++)
                for(j=0;j<8;j++)
                    if(((buffera[k]>>(7-j))&0x1)!=NULL)
                        putpixel(j+x,k+y,color);           /**如果该位非空,则画点***********/
            x+=8;                                    /******屏幕光标偏移量***********************/
        }

    if(x>=getmaxx())
        {  y+=16;
           x=0; }
       }

   fclose(fp);      /*********关闭文件指针*********/
   fclose(fpa);      /*********关闭文件指针*********/
}/******欢迎界面函数***********/
void welcome()
{
                                                 /*****暂未开发******/
}

/*****************功能函数****************/
void jiemian()
{
  setbkcolor(7);
  setcolor(WHITE);
  rectangle(5,5,634,474);
  line(5,24,639,24);
}
void function()
{
jiemian();

}

/*****************退出函数****************/
void thinkused()
{
}
/*****************主函数*****************/
void main()
{
graphini();
welcome();/******欢迎界面*******/
function();/******功能函数****/
thinkused();
closegraph();
}
2010-08-28 17:42
快速回复:Type mismatch in redeclaration of "myprintf! 求解答!
数据加载中...
 
   



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

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