473,382 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

need help

hey, im trying to program a game that lets you buy weapons and sell them on and stuff. obviously more complicated than that but you get my drift. im getting a few errors i cant fix.

function 'glock17' should have a prototype (32)
type mismatch in redeclaration of 'glock17' (106)
misplaced else (149)
misplaced else (159)
function 'weaponm' should have a prototype (190)

cant find anything on prototypes that i can understand

heres the source:

Expand|Select|Wrap|Line Numbers
  1. #include<conio.h>
  2. #include<stdio.h>
  3. int glock;
  4. int glockinv;
  5. int suitcase,cash,buysell;
  6.  
  7.  
  8.  
  9.  
  10.                             void glock17()
  11.                             {
  12.                             char howmuch;
  13.                             int glocktemp,glockinv;
  14.  
  15.  
  16.                             printf("would you like to buy(1) or sell(2) some glock17's?\n\n");
  17.                             scanf("%c",&buysell);
  18.                             if(buysell=1)
  19.                             printf("\nHow many would ya like?");
  20.                             {
  21.                             scanf("%i",&glocktemp);
  22.                               if(glocktemp>200)
  23.                              {
  24.                               printf("\nYou cant buy that much\n");
  25.                               getchar();
  26.                               glock17();
  27.                              }
  28.  
  29.                               else if(glocktemp=0)
  30.                               {
  31.                               void weaponsmark();
  32.                               getchar();
  33.                               glock17();
  34.                               }
  35.  
  36.                               else if(cash<(glocktemp*50)
  37.                               {
  38.                               printf("\nYou Don't have enough money");
  39.                               getchar();
  40.                               glock17();
  41.                               }
  42.                               else
  43.                               {
  44.                               glockinv=weapontemp;
  45.                               suitcase=suitcase-glockinv;
  46.                               cash=cash-(glocktemp*50)
  47.                               printf("\nYou have just bought %i Glocks for %i",glockinv,glocktemp);
  48.                               printf("\nYou have %i glock and %i space left",glockinv, suitcase);
  49.                               getchar();
  50.                               clrscr();
  51.                               weaponsmark();
  52.                              }
  53.                              }
  54.                             else
  55.                             {
  56.                             if (glockinv>1)
  57.  
  58.                             printf("\nHow many would you like to sell?");
  59.                             scanf("%i,"&drugtemp);
  60.                             cash=cash+(glockinv*50)
  61.                             printf("\nYou sold %i's worth of Glocks");
  62.                             glockinv=glockinv-drugtemp;
  63.                             }
  64.                             else
  65.                             Printf("\nyou don't have any Glocks!")
  66.                             weaponsmark();
  67.                             }
  68.                           }
  69.  
  70.  
  71.            void suitcasefunc()
  72.            {
  73.            suitcase=200;
  74.            }
  75.            void cashfunc()
  76.            {
  77.             cash=50000
  78.            }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. void weaponsmark()
  87.  
  88. char weaponm;
  89.  
  90. do
  91. {
  92.  
  93.      printf("\n\t\t a.Buy Glock 17 (Handgun)");
  94.      printf("\n\t\t b.Buy M9 (Shotgun)");
  95.      printf("\n\t\t c.Buy MP7 (Sub Machine Gun)");
  96.      printf("\n\t\t d.Buy M4 (Rifle)");
  97.      printf("\n\t\t e.Buy SV210 (Sniper Rifle)");
  98.      printf("\n\t\t f.Buy Barret 50 .cal (Armor Piercing Rifle)");
  99.      printf("\n\t\t g.Buy M203 (Grenade Launcher)");
  100.      printf("\n\t\t h.Buy LAW 24 (Rocket Launcher)");
  101.      printf("\n\t\t i.Buy Torque Bow (sticky bombs)");
  102.      printf("\n\t\t j.Buy Nuke");
  103.      printf("\n\t\t k.Buy Hammer Of Dawn (ION Cannon)");
  104.      printf("\n\nWeapon Dealer: What kind of boom stick would you like
  105. today, sir?");
  106.      weaponm=getchar();
  107.  
  108.      switch(weaponm)
  109.      {
  110.  
  111.      case 'a':glock17();
  112.           break;
  113.    /*  case 'b':m9();
  114.           break;
  115.      case 'c':mp7();
  116.           break;
  117.      case 'd':m4();
  118.           break;
  119.      case 'e':sv210();
  120.           break;
  121.      case 'f':barret();
  122.           break;
  123.      case 'g':m203();
  124.           break;
  125.      case 'h':law24();
  126.           break;
  127.      case 'i':torque();
  128.           break;
  129.      case 'j':nuke();
  130.           break;
  131.      case 'k':ION();
  132.           break; */
  133.      case 'l':break;
  134.  
  135.      default: printf("\n Invalid Menu Choice");
  136.      getchar();
  137.      }
  138. }
  139. while(weaponm!='l');
  140. printf("\nGoodbye");
  141. getchar();
  142. }
  143.  
  144.  
  145. /*void startmenu()
  146. {
  147. char choice;
  148.  
  149. do
  150. {
  151.     clrscr();
  152.     printf("\n\t\t d.Drugs Market");
  153.     printf("\n\t\t w.Weapons Market");
  154.     printf("\n\t\t b.Buy Upgrade");
  155.     printf("\n\t\t v.View Stats");
  156.     printf("\n\t\t f.Fly");
  157.     printf("\nEnter Choice");
  158.     choice=getchar();
  159.  
  160.     switch(choice)
  161.     {
  162.  
  163.     case 'a':printf("\n\nnumber1");
  164.         getchar();
  165.          break;
  166.  
  167.     case 'b':printf("\n\nnumber2");
  168.          getchar();
  169.          break;
  170.  
  171.     case 'c':break;
  172.  
  173.     default: printf("\n Invalid Menu Choice");
  174.     getchar();
  175.     }
  176. }
  177. while(choice!='c');
  178. printf("\nGoodbye");
  179. getchar();
  180. }
  181.  
  182.  */
  183. void main()
  184. {
  185. cashfunc();
  186. suitcasefunc();
  187. weaponsmark();
  188. weaponm();
  189. }
  190.  
  191.  
  192.  
thanks in advance
Mar 20 '07 #1
1 1133
sicarie
4,677 Expert Mod 4TB
So that's just saying that you need to declare those functions you create. For instance, if I want to create a function that changes celsius to farenheit, it would look something like:
Expand|Select|Wrap|Line Numbers
  1. float celsiusToFarenheit(float faren) {
  2.     float cel = (5/9) * (faren-32);
  3.     return cel;
  4. }
  5.  
However, the compiler needs the prototype to be able to read it, so you would also need to include:
Expand|Select|Wrap|Line Numbers
  1. float celsiusToFarenheit(float faren);
  2.  
Best practice dictates putting this by your headers (though I've never played around with the declarations - I'm not sure it's entirely necessary).

So, for C++:
Expand|Select|Wrap|Line Numbers
  1. include <iostream>
  2. using namespace std;
  3. float celsiusToFarenheit(float faren);
  4. int main()
  5. {
  6.     float temp;
  7.     cout << "Enter a temp: ";
  8.     cin >> temp;
  9.     cout << "The Celsius equivalent is: " << celsiusToFarenheit(temp) << endl;
  10.     return 0;
  11. }
  12.  
  13. float celsiusToFarenheit(float faren) {
  14.     float cel = (5/9) * (faren-32);
  15.     return cel;
  16. }
  17.  
Mar 20 '07 #2

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

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows:...
0
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities,...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.