• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Parse Error?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

26 replies to this topic

### #1IRDumb  Members

Posted 09 October 2001 - 11:40 AM

Whenever I try and compile my code on dev-cpp, I get all these parse error, like on my bracket ({) or something. It says something like this... parse error before ''<'' parse error before ''['' and so on... What is going on?

Posted 09 October 2001 - 12:20 PM

You haven''t given enough information for anybody to help you specifically. The only advice I can give is to start at the top of your error list, not the bottom.

### #3IRDumb  Members

Posted 09 October 2001 - 01:37 PM

Ok, well try this...

(I just did this right now in my compiler, dev)

#include
void main()
{
int age
cout<<"hello world\n";
cout<<"how old are you?\n";
cin>>age;
cout<<"you are"<}

The only error I got was "parse error before <''" in line 5.
Also, when I said, "execute" nothing happened, even though the
box was saying execute.

### #4Colin Jeanne  Members

Posted 09 October 2001 - 01:57 PM

cout<<"you are"<} should be cout<<"you are";}

### #5IRDumb  Members

Posted 09 October 2001 - 02:03 PM

Oops, that was a mistake.

cout<<"you are"<}

### #6Anthracks  Members

Posted 09 October 2001 - 02:06 PM

You need to put a semi-colon ";" after int age...

Also, use the tags [ source ] and [ /source ] (without the extra spaces) around any code you post so it doesn''t think the less than/greater than signs are HTML.

Anthracks

### #7Anonymous Poster_Anonymous Poster_*  Guests

Posted 09 October 2001 - 02:18 PM

Hmm, you should read the FAQ. It explains how to post code without having things get eaten by HTML by using certain special tags. I forget what they are at the moment.

As far as the code you posted, it looks like you''re missing a ; on line 4 after "int age". With C/C++, when the compiler gives an error on a specific line, the problem isn;t necessarily on that line. Often incorrect code on previous lines can''t be detected and reported by the compiler until it reachs a point on a later line.

### #8IRDumb  Members

Posted 09 October 2001 - 02:36 PM

Ok, thanks
After the semicolon it was fine, so I guess I just miss semicolons and stuff. And I''ll do that
  
next time too.
Now another thing-
*Why does''t the program execute even after I compile it no errors? What happens is I click execute, and the top blue status/tool bar thing goes from blue to gray and then returns?

### #9Null and Void  Members

Posted 09 October 2001 - 02:46 PM

It is executing, it is just finishing because it doesn''t have to wait for anything. Make it get input or wait at the end of the program, then it won''t close when it''s done.

[Resist Windows XP''s Invasive Production Activation Technology!]

### #10IRDumb  Members

Posted 10 October 2001 - 04:11 AM

How do I make it wait?
I am not using return 0; or anything

### #11barazor  Members

Posted 10 October 2001 - 04:31 AM

either include stdlib.h and use system("PAUSE") at the end of the program, or include stdio and use getchar()

### #12barazor  Members

Posted 10 October 2001 - 04:32 AM

oh, and also,
cin >> somefakevariable works pretty well, for example

char somefakevariable;
cin >> somefakevariable;

:D

### #13IRDumb  Members

Posted 10 October 2001 - 04:34 AM

Ok, thanks.
I just compiled a few things and they worked!

### #14IRDumb  Members

Posted 10 October 2001 - 07:53 AM

Ok, now I have a new error.
When I try this...
  if(pick1==2) { cout<<"You''re right!\n"; x=x+1; b(); }else if(pick1!=2) { cout<<"Wrong. The correct answer was 2.\n"; b(); }} 

after a question in my trivia game, it compiles with zero errors but after I answer the question in the dos program, it always says wrong no matter what I typed in. Is it a problem with my if/else if statement?

Oh, FYI, "x" is the results thing and "pick1" is the choice they enter.

### #15Oluseyi  Members

Posted 10 October 2001 - 08:02 AM

Again, we need a little more information to help you, such as the type of pick1 (I''ll just assume it''s an int) and the scope of the if-elseif statement black. However, here''s a little tip: since "2" is the only correct answer, do:
if(pick1 == 2){  cout << "You''re right!\n";  // ++x, x++, x+= 1 and x = x+1 are similar.  // Since you don''t care whether it happens before  // or after this statment, use ++x;  ++x;  b();}else{  cout << "Sorry, the answer is 2.\n";   b();} 

The other thing is make sure your pick1 is an integer (int); if it''s a char then it wont behave the way you expect.

### #16IRDumb  Members

Posted 10 October 2001 - 08:13 AM

I tried that and it still didn''t work. Here is the whole thing.
  #include #include void a();void b();void c();void start();void results();int pick, x;void a(){int pick1;cout<<"How many bones are in the human body?\n";cout<<"1. 100\n";cout<<"2. 206\n";cout<<"3. 266\n";cout<<"4. Over 1000\n";cin>>pick;pick=pick1;if(pick1==2) { cout<<"You''re right!\n"; ++x; b(); }else { cout<<"Wrong. The correct answer was 2.\n"; b(); }}void b(){int pick2;cout<<"What is the name of our currenet president?\n";cout<<"1. Ronald Reagan\n";cout<<"2. John Kennedy\n";cout<<"3. Bill Clinton\n";cout<<"4. George Bush\n";cin>>pick;pick=pick2;if(pick2==4) { cout<<"You''re right!\n"; ++x; c(); }else { cout<<"Wrong. The correct answer was 4.\n"; c(); }}void c(){int pick3;cout<<"What is 12x12?\n";cout<<"1. 100\n";cout<<"2. 122\n";cout<<"3. 144\n";cout<<"4. 1212\n";cin>>pick;pick=pick3;if(pick3==3) { cout<<"You''re right!\n"; ++x; results(); }else { cout<<"Wrong. The correct answer was 3.\n"; results(); }}void results(){cout<<"Your score was "<

### #17IRDumb  Members

Posted 10 October 2001 - 09:00 AM

I really am stupid.
All I had to do was take out int pick at the top and pick=pick 3 etc. and it worked fine! Thank you guys for all your help.

Posted 10 October 2001 - 09:07 AM

Ok, here is what you have:

  int pick1;cout<<"How many bones are in the human body?\n";cout<<"1. 100\n";cout<<"2. 206\n";cout<<"3. 266\n";cout<<"4. Over 1000\n";cin>>pick;pick=pick1;if(pick1==2){ cout<<"You''re right!\n"; ++x; b();}else{ cout<<"Wrong. The correct answer was 2.\n"; b();}

Look at these two lines in particular:
  cin>>pick;pick=pick1;

it should be:
  pick1=pick;

otherwise you overwrite the value you read in with the uninitialized value that was in pick1 when the routine was put on the stack.

Remeber your assignment ordering. The variable to left of the operator receives the value from the variable to the right of the operator.

Posted 10 October 2001 - 09:08 AM

Well, you musta posted right after I hit post reply!

### #20IRDumb  Members

Posted 10 October 2001 - 09:32 AM

Ok, I promise, this is the last parse error. I added a lot to the program and I can get it down to one error:
Parse error at end of input

I didn''t change int main() at all so why is it saying parse error at end of input?
I would post the new thing up there but it is really long(like 175 lines) so if you can help, thanks.
My e-mail is "Rick__33@hotmail.com" if you want to see it.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.