473,626 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I made a program but when i compile it, it says error to many types in declaration

1 New Member
I made a program but when I compile it, it says error to many types in declaration.

Expand|Select|Wrap|Line Numbers
  1. #include<graphics.h>
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<process.h>
  5. #include<dos.h>
  6. #include<math.h>
  7. #include<stdlib.h>
  8.  
  9.  
  10.  
  11. int BirdSpeed=0;
  12. int BirdColor=0;
  13. int AngleProjection=0;
  14. int Velocity=0;
  15. int Power=0;
  16. int Lives=0;
  17. int Level=1;
  18. int Pigs=0;
  19. int TotalPigs=0;
  20. int PigCx[5];
  21. int PigCy[5];
  22. int PigSz[5];
  23.  
  24.  
  25. void Blast();
  26. void PlayGame();
  27. void BirdMenu();
  28. void GameInput();
  29. void Scene();
  30. void MenuChoice();
  31. void MakeMenu();
  32. void Pig(int,int,int);
  33. void Instructions();
  34. void EndScreen();
  35.  
  36. void EndScreen(int x)
  37. { switch(x)
  38.   {
  39.    case 1:
  40.     cleardevice();
  41.   settextstyle(TRIPLEX_FONT,0,8);
  42.   setcolor(RED);
  43.   outtextxy(240,30," RIP ");
  44.   setcolor(WHITE);
  45.   settextstyle(DEFAULT_FONT,0,1);
  46.   outtextxy(240,200,"\n You Died \n");
  47.   outtextxy(240,240,"\n Level:             \n");
  48.   outtextxy(240,280,"\n Pigs Killed:       \n");
  49.   char level[10];
  50.   char killedpigs[10];
  51.   int killed=TotalPigs-Pigs;
  52.   itoa(killed,killedpigs,10);
  53.   itoa(Level,level,10);
  54.   outtextxy(310,240,level);
  55.   outtextxy(360,280,killedpigs);
  56.   setcolor(GREEN);
  57.   outtextxy(240,300,"Restart?(Y/N)");
  58.   char ch=getch();
  59.   if(ch=='y')
  60.     BirdMenu();
  61.  
  62.   else
  63.     exit(0);
  64.   break;
  65.  
  66.   case 2:
  67.     cleardevice();
  68.   settextstyle(TRIPLEX_FONT,0,8);
  69.   setcolor(RED);
  70.   outtextxy(240,30," Congrats ");
  71.   setcolor(WHITE);
  72.   settextstyle(DEFAULT_FONT,0,1);
  73.   outtextxy(240,200,"\n You Won!!!! \n");
  74.   outtextxy(240,240,"\n Level:             \n");
  75.   outtextxy(240,280,"\n Pigs Killed:       \n");
  76.   char level2[10];
  77.   char killedpigs2[10];
  78.   int killed2=TotalPigs-Pigs;
  79.   itoa(killed2,killedpigs2,10);
  80.   itoa(Level,level2,10);
  81.   outtextxy(310,240,level2);
  82.   outtextxy(360,280,killedpigs2);
  83.   setcolor(GREEN);
  84.   outtextxy(240,300,"Restart?(Y/N)");
  85.   char ch1=getch();
  86.   if(ch1=='y')
  87.     BirdMenu();
  88.  
  89.   else
  90.     exit(0);
  91.   break;
  92.    }
  93.  }
  94. void Blast(int x, int y,int r)
  95. {
  96.    float i;
  97.    for(i=0;i<=r;i=i+1)
  98.    {
  99.  
  100.     setcolor(14);
  101.     circle(x,y,i);
  102.     sound(i*100);
  103.     delay(1);
  104.     setcolor(0);
  105.     circle(x,y,i);
  106.     nosound();
  107.    }
  108.    }
  109.  
  110.    void Collision(int birdcx,int birdcy)
  111.     {
  112.     for(int i=1;i<=TotalPigs;i++)
  113.     {
  114.        if(PigSz[i]==0)
  115.         continue;
  116.  
  117.        if((birdcx>=(PigCx[i]-PigSz[i]-9)&&birdcx<=(PigCx[i]+PigSz[i]))&&((birdcy>=(PigCy[i]-PigSz[i])-9)&&(birdcy<=(PigCy[i]+PigSz[i]+9))))
  118.         {
  119.         Blast(PigCx[i],PigCy[i],PigSz[i]);
  120.         PigSz[i]=0;
  121.         Pigs--;
  122.         }
  123.     }
  124.  
  125.     }
  126.  
  127.  void Level_1_Scene()
  128.  { Lives=2;
  129.    Pigs=TotalPigs=1;
  130.    PigCx[1]=200;PigCy[1]=300;PigSz[1]=10;
  131.    Pig(200,300,10);
  132.  }
  133.  void Level_2_Scene()
  134.  { Lives=3;
  135.    Pigs=TotalPigs=2;
  136.    PigCx[1]=580;PigCy[1]=400;PigSz[1]=10;
  137.    PigCx[2]=540;PigCy[2]=400;PigSz[2]=15;
  138.    int pigs=Pigs;
  139.    while(pigs>0)
  140.    { Pig(PigCx[pigs],PigCy[pigs],PigSz[pigs]);
  141.      pigs--;   }
  142.    }
  143.  void Level_3_Scene()
  144.  { Lives=4;
  145.  Pigs=TotalPigs=4;
  146.  PigCx[1]=580;PigCy[1]=400;PigSz[1]=10;
  147.  PigCx[2]=600;PigCy[2]=400;PigSz[2]=10;
  148.  PigCx[3]=620;PigCy[3]=400;PigSz[3]=10;
  149.  PigCx[4]=600;PigCy[4]=350;PigSz[4]=20;
  150.  int pigs=Pigs;
  151.    while(pigs>0)
  152.    { Pig(PigCx[pigs],PigCy[pigs],PigSz[pigs]);
  153.      pigs--;   }
  154.  }
  155.  void Pig(int cx,int cy,int sz)
  156.  {
  157.   setcolor(GREEN);
  158.   circle(cx,cy,sz);
  159.   circle(cx,cy+3,sz/3);
  160.   setcolor(WHITE);
  161.   circle(cx+3,cy-3,2);
  162.   circle(cx-3,cy-3,2);
  163.  
  164.  }
  165.  void Bird(int cx,int cy)
  166. {
  167.  setlinestyle(0,0,3);
  168.  setcolor(BirdColor);
  169.  circle(cx,cy,10);
  170.  setcolor(WHITE);
  171.  line(cx-8,cy-8,cx-1,cy-1);
  172.  line(cx+8,cy-8,cx+1,cy-1);
  173.  setcolor(YELLOW);
  174.  line(cx-8,cy+3,cx+8,cy+3);
  175.  /*
  176.  line(cx,cy,cx+6,cy+3);
  177.  line(cx+6,cy+3,cx,cy+3);
  178.  line(cx,cy,cx,cy+6);
  179.    */
  180. }
  181.  void ClrBird(int cx,int cy)
  182. {
  183.  setlinestyle(0,0,3);
  184.  setcolor(BLACK);
  185.  circle(cx,cy,10);
  186.  line(cx-8,cy-8,cx-1,cy-1);
  187.  line(cx+8,cy-8,cx+1,cy-1);
  188.  line(cx-8,cy+3,cx+8,cy+3);
  189. }
  190.  
  191. void MenuChoice()
  192. { char choice;
  193.  choice=getch();
  194.  sound(500);
  195.  delay(100);
  196.  nosound();
  197.  switch(choice)
  198.  
  199.  {
  200.   case 's':
  201.   BirdMenu();
  202.   break;
  203.  
  204.  
  205.   case 'e':
  206.   exit(0);
  207.   break;
  208.  
  209.   default:
  210.   EndScreen(1);
  211.   }
  212. }
  213. void MakeMenu()
  214. {
  215.   cleardevice();
  216.   settextstyle(DEFAULT_FONT,0,6);
  217.   outtextxy(60,110,"ANGRY BIRDS");
  218.   settextstyle(DEFAULT_FONT,0,1);
  219.   setcolor(BLUE+BLINK);
  220.   outtextxy(100,200,"(S)START");
  221.   setcolor(RED+BLINK);
  222.   outtextxy(100,280,"(E)EXIT");
  223.  
  224.   do
  225.   {int n;
  226.   n=0;
  227.   while( n<30)
  228.  {if(kbhit()!=0)
  229.     goto endanim;
  230.  BirdColor=(n%10)+1;
  231.   Bird(400,300+(5*n));
  232.  BirdColor=(n%10)+2;
  233.   Bird(430,300+(5*n));
  234.  BirdColor=(n%10)+3;
  235.   Bird(450,300+(5*n));
  236.   ClrBird(400,300+(5*n));
  237.   ClrBird(430,300+(5*n));
  238.   ClrBird(450,300+(5*n));
  239.   n++;
  240.   }
  241.    while( n>=30)
  242.  {
  243.   if( kbhit()!=0)
  244.    goto endanim;
  245.  BirdColor=(n%10)+1;
  246.   Bird(400,(5*n)+300);
  247.  BirdColor=(n%10)+2;
  248.   Bird(430,(5*n)+300);
  249.  BirdColor=(n%10)+3;
  250.   Bird(450,(5*n)+300);
  251.   ClrBird(400,(5*n)+300);
  252.   ClrBird(430,(5*n)+300);
  253.   ClrBird(450,(5*n)+300);
  254.   n--;
  255.   }
  256.  
  257.   } while(1);
  258.   endanim:
  259.   MenuChoice();
  260. }
  261. void BirdMenu()
  262. {
  263.   cleardevice();
  264.   settextstyle(DEFAULT_FONT,0,4);
  265.   setcolor(CYAN);
  266.   outtextxy(20,20,"Choose a bird");
  267.   settextstyle(SMALL_FONT,0,7);
  268.   setcolor(RED);
  269.   outtextxy(40,60,"(R)RED");
  270.   outtextxy(50,80,"Speed:*** \n Luck:***** \n Special Move:DROP");
  271.   setcolor(YELLOW);
  272.   outtextxy(40,120,"(Y)YELLOW");
  273.   outtextxy(50,140,"Speed:***** \n Luck:*** \n Special Move:BOOST");
  274.   setcolor(BLUE);
  275.   outtextxy(40,180,"(B)BLUE");
  276.   outtextxy(50,200,"Speed:**** \n Luck:**** \n Special Move:BOMB");
  277.   setcolor(WHITE);
  278.   outtextxy(40,250,"(E)Exit");
  279.  
  280. char inp=getch();
  281.  
  282.  sound(900);
  283.  delay(100);
  284.  nosound();
  285.  
  286.   if(inp=='r')
  287.     { BirdSpeed=3;BirdColor=4;}
  288.   if(inp=='y')
  289.     { BirdSpeed=4;BirdColor=14;}
  290.   if(inp=='b')
  291.     { BirdSpeed=4;BirdColor=1;}
  292.   else if(inp=='e')
  293.     { MakeMenu(); }
  294.     Instructions();
  295. }
  296.  
  297.  
  298.  
  299. void Instructions()
  300. {
  301. cleardevice();
  302.   settextstyle(TRIPLEX_FONT,0,3);
  303.   setcolor(RED);
  304.   outtextxy(20,20,"Instructions");
  305.   setcolor(YELLOW);
  306.   settextstyle(DEFAULT_FONT,0,1);
  307.   outtextxy(20,70,"Press W to increase the power");
  308.   outtextxy(20,90,"Press S to decrease the power");
  309.   outtextxy(20,110,"Press A to increase the angle");
  310.   outtextxy(20,130,"Press D to decrease the angle");
  311.   setcolor(GREEN);
  312.   outtextxy(20,170,"Press Spacebar to launch");
  313.   outtextxy(20,190,"Press N for special move");
  314.   setcolor(WHITE);
  315.   outtextxy(20,230,"Press any key to continue");
  316.   getch();
  317.   sound(800);
  318.   delay(100);
  319.   nosound();
  320.   Scene();
  321. }
  322. void Scene()
  323. {
  324.     cleardevice();
  325.     setcolor(GREEN);
  326.     line(0,420,650,420);
  327.     setlinestyle(SOLID_LINE,1,THICK_WIDTH);
  328.     setfillstyle(HATCH_FILL,RED);
  329.     floodfill(10,455,GREEN);
  330.     setcolor(BROWN);
  331.     line(75,420,75,380);
  332.     line(85,420,85,380);
  333.     line(75,380,65,370);
  334.     line(85,380,95,370);
  335.     setcolor(RED);
  336.     line(65,370,70,370);
  337.     line(85,370,95,370);
  338.     Level_1_Scene();
  339.    {
  340.       while(Lives>=0 && Pigs>0)
  341.        { GameInput(); Lives--;}
  342.  
  343.    if(Lives>=0)
  344.    { Level++;
  345.      Level_2_Scene();
  346.       while(Lives>=0 && Pigs>0)
  347.     { GameInput(); Lives--;}
  348.  
  349.  
  350.      if(Lives>=0)
  351.     {Level++;
  352.      Level_3_Scene();
  353.        while(Lives>=0 && Pigs>0)
  354.     { GameInput(); Lives--;}
  355.     if(Lives>=0)
  356.      EndScreen(2);
  357.      }
  358.      else
  359.       EndScreen(1);
  360.     }
  361.     else
  362.      EndScreen(1);
  363.   }
  364.   }
  365.     void GuideLine(int power,int angle,int color)
  366.     {
  367.     float a_rad=angle*(3.14156/180);
  368.     setcolor(color);
  369.     setlinestyle(DOTTED_LINE,0,3);
  370.     line(80,370,80+(power*cos(a_rad)),370+(power*sin(a_rad)));
  371.     }
  372.     void ClrGuideLine(int power,int angle)
  373.     {
  374.  
  375.     float a_rad=angle*(3.14156/180);
  376.     setcolor(BLACK);
  377.        setlinestyle(DOTTED_LINE,0,3);
  378.        line(80,370,80+(power*cos(a_rad)),370+(power*sin(a_rad)));
  379.     }
  380.  
  381.  void GameInput()
  382.     {  setfillstyle(SOLID_FILL,BLACK);
  383.        bar(0,0,200,100);
  384.       int color=0;
  385.     AngleProjection=360;
  386.     Power=20;
  387.     GuideLine(20,360,2);
  388.     Bird(80,370);
  389.     char ch;
  390.     setfillstyle(SOLID_FILL,RED);
  391.     outtextxy(50,20,"Lives :");
  392.     bar(120,20,Lives*10+120,25);
  393.     setfillstyle(SOLID_FILL,BLUE);
  394.     outtextxy(50,50,"Pigs Left  :");
  395.     bar(150,50,Pigs*10+150,55);
  396.     setfillstyle(SOLID_FILL,YELLOW);
  397.     outtextxy(50,80,"Level :");
  398.     bar(120,80,Level*10+120,85);
  399.  
  400.     while((ch=getch())!=' ')
  401.     {
  402.        ClrGuideLine(Power,AngleProjection);
  403.         if(ch==97&&AngleProjection>270)
  404.         AngleProjection-=5;
  405.  
  406.          if(ch==100&&AngleProjection<360)
  407.            AngleProjection+=5;
  408.  
  409.         if(ch==119&&Power<30)
  410.            Power+=5;
  411.  
  412.         if(ch==115&&Power>5)
  413.         Power-=5;
  414.      if(Power<=15)
  415.           color=2;
  416.      else if(Power>15&&Power<=20)
  417.           color=14;
  418.      else if(Power>20)
  419.           color=4;
  420.  
  421.      GuideLine(Power,AngleProjection,color);
  422.      Bird(80,370);
  423.     }
  424.  
  425.     ClrGuideLine(Power,AngleProjection);
  426.     PlayGame();
  427.  
  428.     }
  429. void PlayGame()
  430. {
  431.   float t,a_rad;
  432.   int x=80,y=370;
  433.   int oldx,oldy;
  434.     a_rad=(360-AngleProjection)*3.141592/180;
  435.  
  436.     for(t=0;y<=420 &&x<=640 && x>=0;t+=0.02)
  437.     {
  438.     oldx=x;
  439.     oldy=y;
  440.  
  441.     x+=(Power*BirdSpeed*0.25*cos(a_rad)*t);
  442.     y-=((Power*0.8*sin(a_rad)*t)-(15*t*t));
  443.  
  444.     if(kbhit()!=0)
  445.         { char ch;
  446.         ch=getch();
  447.         if(ch=='n')
  448.         {if(BirdColor==RED)
  449.         Power=0;
  450.          if(BirdColor==YELLOW)
  451.         Power+=30;
  452.          if(BirdColor==BLUE)
  453.         {int Rand;
  454.          Rand=rand()%10;
  455.          if(Rand%2==0)
  456.            BirdColor=RED;
  457.          else
  458.            BirdColor=YELLOW; }
  459.         }
  460.         }
  461.     Collision(x,y);
  462.     ClrBird(oldx,oldy);
  463.     Bird(x,y);
  464.  
  465.  
  466.      }
  467.    getch();
  468.    ClrBird(x,y);
  469.  
  470. }
  471.  
  472. void main()
  473. {
  474.     int driver,mode;
  475.     driver=DETECT;
  476.     initgraph(&driver,&mode,"C:\\turboC3\\bgi\\");
  477.  
  478.     MakeMenu();
  479.  
  480.     closegraph();
  481. }
Jun 12 '17 #1
1 1407
donbock
2,426 Recognized Expert Top Contributor
Which statement is associated with the line number that accompanies the error message?

My first guess is that one of your variable names is inadvertently the same as that of a typedef in one of the header files you're including.

It would help a lot if you enclosed your source code in CODE tags. That would preserve the formatting and, most importantly, provide line numbers that we could reference.

What compiler are you using?
The versions of C that I'm most familiar will complain if variable declarations are anywhere other than the first statements in a curly-brace block. For example, the declaration of level after the call to outtextxy() in function EndScreen().

You should convert the function declarations at the start of the file into function prototypes by specifying the argument types. For example, change "void Blast();" to "void Blast(int x, int y, int r);"
Jun 16 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
8110
by: user | last post by:
Hi, I got this error and donno know how to fix it: In file included from ../except.h:53, from group.c:22: .../portspecs.h:81: error: conflicting types for `const double __infinity' /usr/include/math.h:26: error: previous declaration as `const __dmath __infinity'
12
9196
by: tienlx | last post by:
Hi, I'm learning C++, i wrote a small project that has these files: Log.h Log.cpp Render.h Render.cpp Tid.h
5
3169
by: fimarn | last post by:
I am trying to get rid of compile time error that I am getting only in RHEL5 (not in RHEL4) apparently due to the changes in the stl_list.h file. The error that I am getting is coming from the following code that attempts to remove an item from the list: class shm_objptr_list : public std::list < void*, SharedMemAlloc<void * > {
11
4261
by: Bryan Crouse | last post by:
I am looking a way to do error checking on a string at compile time, and if the string isn't the correct length have then have the compiler throw an error. I am working an embedded software that will require individual builds for each device so that the device serial number is contained in the program memory. To do this, the C application must be compiled with the serial number assigned to a variable within the source code file. I...
5
7825
by: TalonStriker | last post by:
Hi guys, When I compile this code, I'm getting the following error: warning: implicit declaration of function 'strdup' I've included <string.h> and <wchar.h> so I shouldn't be getting the error right? The line of code in question is: //some declarations inside a static function
6
1730
by: fishwater00 | last post by:
Question 1: typedef struct { int x, y, z ; float *wave; float *velocity; }Model; void a(Model *domain); void b(Model *domain, int t);
3
5625
Fr33dan
by: Fr33dan | last post by:
I'm a long time Java guy trying to move to C++ but I keep getting this error that I can't seem to figure out. It must be something simple I'm missing but I can't find it by looking at examples. I get a "Too many types in declaration" on my class declaration line: #include<string> #include<vector> #include"MapCoordinates.h" class TopographicalMap //Error: Too many types in declaration { private:
3
17178
by: AYESHA Jabeen | last post by:
it is a simple program that is demonstrating class and object.but it is giving an error like too many types in declaration and function should return a value.... pls find solution and suggest me what should i do... #include<iostream.h> #include<conio.h> class ayes { public: void foo()
1
2118
by: earthempire | last post by:
I'm a student now learning struct with array turbo c++ 4.5 and it crashed when compile this code no error message just crash. is the code wrong or anything please help. #include<stdio.h> #include<conio.h> void main()
2
2696
by: mohapatramugdha | last post by:
This is my program #include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<math.h> struct date
0
8711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.