Friday, May 21, 2010

There is an error in my c++ program, help?

I cant find the errors on my program





these are my errors








: 'CarOrFight' : local function definitions are illegal


: end of file found before the left brace '{' at 'U:\game.cpp(171)' was matched












































#include %26lt;iostream.h%26gt;


int Gas();


int Gun();


int CarOrFight();





int main()


{


cout %26lt;%26lt;"Your an agent\n\n";


cout %26lt;%26lt; "The goverment sent you to investigate missing people in\nCosta Rico";


cout %26lt;%26lt; "\n\nYour in the woods, you see houses every half a mile\n\n";


cout %26lt;%26lt;"Your partner, Alex, tells you that you are running out of gas";


cout %26lt;%26lt;"You want to get to the town soon to investigate, but you are afraid you will run out of gas\n\n";


cout %26lt;%26lt;"You noticed that you just passed a gas station\n\n";


cout %26lt;%26lt;"You can turn back choice 1 \n";


cout %26lt;%26lt;"\n\nor\n\n";


cout %26lt;%26lt;"Get to town before gas runs out choice 2\n";


Gas();


return 0;


}

















int Gas()


{


enum Gas{turn=1,go};





int choice;


cin %26gt;%26gt; choice;


if (choice==turn)

There is an error in my c++ program, help?
We'll need the end of your code to help you...
Reply:Both errors are probably because you have a "{" (left brace) symbol but never put in the matching "}" (right brace) symbol, for example at the end of a function.





Go through your code and make sure every brace is in its place.
Reply:Your post looks to be incomplete or cutoff. Regardless, I can tell you what to look for. You most like forgot a semi-colon at end of statement. Or you forgot a closing/opening parens or brace. Hopefully you are using a proper code editor to edit your code. Such editors will highlight your code and indent it properly.


No comments:

Post a Comment