here is my code.
It is an IPM sim for the browser game XNova. However when I compile it I am getting a load of errors. I am used to php telling me the exact error and the line however the error I am getting don't make sense to me. Prehaps someone could help explain.Code:#include <stdio.h> /* Info */ /* Num - Name 401 - Rocket Launcher 402 - Light Laser 403 - Heavy Laser 404 - Gauss Cannon 405 - Ion Canon 406 - Plasma Turret 407 - Small Shield Dome 408 - Lage Shield Dome 409 - Small Grav Dome 410 - Large Grav Dome -- 502 - ABM 503 - IPM */ main() { /* Defind the variables that will be used. */ int item[502],item[503],missiles; int item[401],item[402],item[403],item[404],item[405],item[406],item[407],item[408],item[409],item[410]; int item[401][s],item[402][s],item[403][s],item[404][s],item[405][s],item[406][s],item[407][s],item[408][s],item[409][s],item[410][s]; int weapons_tech,id; int randomDefense,selectionDefense; char name[401],name[402],name[403],name[404],name[405],name[406],name[407],name[408],name[409],name[410]; /* First lets set the names */ name[401] = "Rocket Launcher"; name[402] = "Light Laser"; name[403] = "Heavy Laser"; name[404] = "Gauss Cannon"; name[405] = "Ion Canon"; name[406] = "Plasma Turret"; name[407] = "Small Shield Dome"; name[408] = "Lage Shield Dome"; name[409] = "Small Gravity Dome"; name[410] = "Large Gravity Dome"; /* Set the shield caps */ item[401][s] = 20; item[402][s] = 25; item[403][s] = 100; item[404][s] = 200; item[405][s] = 500; item[406][s] = 300; item[407][s] = 2000; item[408][s] = 10000; item[409][s] = 2000000; item[410][s] = 10000000; /* Title */ printf("IPM Simulator for Darkness of Evolution\nBy Anthony (MadnessRed) - [http://madnessred.co.cc]\n\n"); /* How many IPMS? */ printf("How many IPMs are you firing?\n"); scanf("%i", &item[503]); /* How many ABMs? */ printf("\nHow many ABMs does you opponent have?\n"); scanf("%i", &item[502]); /* Stage 1 - ABS are fired against IPMS */ item[503] = item[503] - item[502]; printf("\nEnter you weapon tech level.\n"); scanf("%i", &weapons_tech); /* Are there any left? */ if (item[503] <= 0){ /* No there aren't */ printf("\nAll your IPMs have been destroyed. The defender still has %i ABMS\n",(1 - item[503])); }else{ /* Yes there are */ /* So there are 0 ABMS now. */ item[502] = 0; printf("\nAfter facing the defenders ABS you have %i APMs left.\n",item[503]); printf("\nNow you will need to enter the defenders stats."); /* Now a loop for inserting each defence for opponent */ for ( id = 401; id < 411; id++ ) { printf("\n%s: "name[id]); scanf("%i", &item[id]); } /* lets work out new score. */ puissanceAttaque = (item[503] * 12000) * (1.05 * weapons_tech); /* PHP Code */ /* while ($PuissanceAttaque > 20) { $RandomDefense = rand(401, 410); $SelectionDefense = $DefenseAdversaire[$RandomDefense]; if ($SelectionDefense > 0) { if ($PuissanceAttaque > ($SelectionDefense * $TableauDeDefense[$RandomDefense])) { $PuissanceAttaque = $PuissanceAttaque - ($SelectionDefense * $TableauDeDefense[$RandomDefense]); $DefenseAdversaire[$RandomDefense] = $DefenseAdversaire[$RandomDefense] - 1; } } } */ while (puissanceAttaque > 20) { randomDefense = (rand()%10)+400; selectionDefense = item[randomDefense]; if (selectionDefense > 0) { if (puissanceAttaque > (selectionDefense * item[randomDefense][s])) { puissanceAttaque = puissanceAttaque - (selectionDefense * item[randomDefense][s]); item[randomDefense] = item[randomDefense] - 1; } } } /* Now a loop for repeating back the defence scores */ printf("\nCalculating Attack, in huge attacks this might take a while.\n\n"); printf("After the attack the defender has.\n"); for ( id = 401; id < 411; id++ ) { printf("%s: %i\n",name[id],item[id]); } } } /*Script by Anthony (MadnessRed) (c) 2008 - http://madnessred.co.cc */
Copy and paste from terminal is..
for example there is an errormadnessred@anthony-desktop:~/Programs/Basic$ gcc -o ipmsim -lm ipmsim.c
ipmsim.c: In function ‘main’:
ipmsim.c:47: error: conflicting types for ‘item’
ipmsim.c:47: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:47: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:48: error: conflicting types for ‘item’
ipmsim.c:48: error: previous declaration of ‘item’ was here
ipmsim.c:49: error: ‘s’ undeclared (first use in this function)
ipmsim.c:49: error: (Each undeclared identifier is reported only once
ipmsim.c:49: error: for each function it appears in.)
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:52: error: conflicting types for ‘name’
ipmsim.c:52: error: previous declaration of ‘name’ was here
ipmsim.c:55: warning: assignment makes integer from pointer without a cast
ipmsim.c:56: warning: assignment makes integer from pointer without a cast
ipmsim.c:57: warning: assignment makes integer from pointer without a cast
ipmsim.c:58: warning: assignment makes integer from pointer without a cast
ipmsim.c:59: warning: assignment makes integer from pointer without a cast
ipmsim.c:60: warning: assignment makes integer from pointer without a cast
ipmsim.c:61: warning: assignment makes integer from pointer without a cast
ipmsim.c:62: warning: assignment makes integer from pointer without a cast
ipmsim.c:63: warning: assignment makes integer from pointer without a cast
ipmsim.c:64: warning: assignment makes integer from pointer without a cast
ipmsim.c:107: error: expected ‘)’ before ‘name’
ipmsim.c:112: error: ‘puissanceAttaque’ undeclared (first use in this function)
warning: assignment makes integer from pointer without a cast
however I don't know what an assignment, pointer or a cast is.
any help would be great.
thanks
MadnessRed
ps I have read posts with the poster being crucified for posting because everyone says that he is cheating on there college homework. I don't expect this as I am not asking for some1 to do it for me, just to help explain the errors to me and what I am doing wrong.