type mismatch in redeclaration of rect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siva25051990
    New Member
    • Oct 2013
    • 1

    #1

    type mismatch in redeclaration of rect

    KUMARACC.C
    ----------

    Code:
    #include<stdio.h>
    #include<dos.h>
    #include<conio.h>
    #include "d:\kumaracc\button.c"
    #include "d:\kumaracc\hvline.c"
    #include "d:\kumaracc\label.c"
    #include "d:\kumaracc\rect.c"
    #include "d:\kumaracc\rmbutton.c"
    #include "d:\kumaracc\textbox.c"
    
    # define ALT_A 7680
    # define ALT_L 9728
    # define ALT_X 11520
    void main(){
    	int key,c;
    	do{
    		clrscr();
    		printf("Enter choice\n");
    		printf("\n1. hvline\n2. label\n3. rect\n4. rmbutton\n5. textbox\n7. button\n6. Exit\n");
    		scanf("%d",&c);
    		switch(c){
    			case 1 :     hline(10,10,20,'*');
    						 vline(10,12,22,'*');
    						 getch();
    						 break;
    			case 2 : label(10,10,3,4,"DBList");
    					 getch();
    						 break;
    			case 3 : rect(10,10,30,12,'*','|');
    						getch();
    						break;
    			case 4 : rmbutton(10,10);
    						getch();
    						break;
    			case 5 : textbox(10,10,30);
    						getch();
    						break;
    			case 7 : button(10,10,"Open");
    					 getch();
    					 break;
    			case 6 : exit(0);
    		}
    	}while(1);
    }
    
    
                              HVLINE.C
                              --------
    
    //	LS = LineSymbol
    int i;
    void hline(int x,int y,int x1,char LS){
    	for(i=x;i<=x1;i++){
    		gotoxy(i,y);
    		printf("%c",LS);
    	}
    }
    void vline(int x,int y,int y1,char LS){
    	for(i=y;i<=y1;i++){
    		gotoxy(x,i);
    		printf("%c",LS);
    	}
    }
    
    
                           RECT.C
                           ------
    
    //	LS = Line Symbol
    void rect(int x,int y,int x1,int y1,char LS,char LS1){
    	hline(x,y,x1,LS);
    	hline(x,y1,x1,LS);
    	vline(x,y+1,y1-1,LS1);
    	vline(x1,y+1,y1-1,LS1);
    }
    
                            BUTTON.C
                            --------
    
    //CL = Character Length
    void button(int x,int y,char *Caption){
    	int CL;
    	CL=strlen(Caption);
    	rect(x,y-1,x+CL+3,y+1,'*','*');
    	gotoxy(x+2,y);
    	printf("%s",Caption);
    }
    
    
                          TEXTBOX.C
                          ---------
    
    //	ML = Maximum Length
    void textbox(int x,int y,int ML){
    	rect(x,y,x+ML+1,y+2,'-','|');
    }
    
                          RMBUTTON.C
                          ----------
    
    //	rmbutton = Record Move Button
    void rmbutton(int x,int y){
    	int i;
    	rect(x,y-1,x+16,y+1,'þ','þ');
    	for(i=x+4;i<=x+12;i=i+4){
    		gotoxy(i,y);
    		printf("þ");
    	}
    	gotoxy(x+2,y);
    	printf("F");
    	gotoxy(x+6,y);
    	printf("P");
    	gotoxy(x+10,y);
    	printf("N");
    	gotoxy(x+14,y);
    	printf("L");
    }
    Last edited by Rabbit; Oct 3 '13, 03:46 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I don't get the error about a type mismatch for a redeclaration of rect in the code you posted.

    However, this is not correct:

    Code:
    #include "d:\kumaracc\button.c"
    #include "d:\kumaracc\hvline.c"
    #include "d:\kumaracc\label.c"
    #include "d:\kumaracc\rect.c"
    #include "d:\kumaracc\rmbutton.c"
    #include "d:\kumaracc\textbox.c"
    You do not include source code files in a source code file. This is the same as inserting a copy of the file itself. So if file A.c includes B.c and C.c and B.c also includes C.c you get redefinition errors because there are two copies of C.c and the code will never compile.

    Instead you use a project to contain the source files and you use header files to declare functions leaving the linker the job of combining all the object files into your .exe.

    You might want to read up on the C/C++ build process.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Do any of those other c files also include rect.c?

      By the way, main() should return an int. You should not define it as returning void.

      Comment

      Working...