Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jcdenton999

C++ Problem..

This topic is 5638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone please tell me what is wrong with this program. I can''t find any errors. The compiler has said: Line 34 - parse error before `<'' and Line 48 - parse error at end of input #include <iostream> using namespace std; int main() { char c; while(true) { cout <<"MAIN MENU: " <)"; cin >> c; if (c==''q'') { break; if (c==''l'') { cout <<"LEFT MENU: " <> c; if (c==''a'') { cout << "You chose ''a''!!!" <> c; if (c==''c'') { cout << "You chose ''c''!"; <

Share this post


Link to post
Share on other sites
Advertisement
Whoa, that program is full of errors. < cout, < continue, < }, etc. are all illegal. You seem to be missing braces (or have too many), in several places. You're also missing some semicolons.

Maybe the forum screwed up the code. Try putting it between [ source ] and [ /source ] tags (without the spaces).

[edited by - micepick on April 19, 2003 4:25:12 PM]

Share this post


Link to post
Share on other sites
you''re using the cout function incorrrectly in several places:

Change

cout <<"MAIN MENU: " )";

and similar, to

cout <<"MAIN MENU: " << "Enter -- (l:left) (r:right) (q:quit =>)";

and change

cout <<"You didn''t choose c or d!" <}

to

cout <<"You didn''t choose c or d!";

I''ll be honest with you, and please don''t take offense. You will need to take some tutorials on C++ before attempting to use the language for game programming.

Good luck.

Share this post


Link to post
Share on other sites
Sorry...I dunno what the hell happened with the code. I''ll try to put it between source tags but I dunno if that will work.
All the

  
#include <iostream>
using namespace std;
int main()
{
char c;
while(true)
{
cout <<"MAIN MENU: " <<endl;
cout <<"Enter -- (l:left) (r:right) (q:quit =>)";
cin >> c;
if (c==''q'')
{
break;
if (c==''l'')
{
cout <<"LEFT MENU: " <<endl;
cout <<"Select a or b: ";
cin >> c;
if (c==''a'')
{
cout << "You chose ''a''!!!" <<endl;
continue;
}
if (c==''b'') {
cout << "You chose ''b''!" <<endl;
continue;
}}
if (c==''r'') {
cout <<"RIGHT MENU: " <<endl;
cout <<"Select c or d: ";
cin >> c;
if (c==''c'')
{
cout << "You chose ''c''!"; <<endl;
continue;
}
if (c==''d'')
{
cout <<"You chose ''d''" <<endl;
continue;
}
else
{
cout <<"You didn''t choose c or d!" <<endl;
}
cout << "Quitting menu....." <<endl;
}


Anyway---any problems with this.

Share this post


Link to post
Share on other sites
Do some indentation. The way it looks to me, your braces are badly mismatched (you''re missing some closing ones). Of course, that may be intentional but it''s hard to tell what you''re doing without any indentaion and so many nested ifs.

Share this post


Link to post
Share on other sites
It''s a slow day, and I need practice doing the error thing without using my compiler anyways Lesse...

Dunno whether it will compile as an error, but some whitespace between the #include the using commands would be good...

Indenting would also be nice, although I''ve seen forums screw that over before, so I won''t nail ya to the wall over it. (This time )

Missing a closing brace on the first if. (Just after the break) (Presumably the cause of your second error)

Logic error...

You''ll only get the Quitting Menu message if you select something from the right menu.

I get those on my first pass through, if I could be bothered copy-pasting to a compiler window, might be able to find more. I would like to reiterate that layout is very important to good, readable code. Get in the habit early, and you can sit on a high-horse and bitch about others not doing it too. It makes you feel surprisingly superior :D

Press to test... *click* Release to detonate...

Share this post


Link to post
Share on other sites
quote:
Original post by Faradhi
Dunno whether it will compile as an error, but some whitespace between the #include the using commands would be good...


That''s a bug in the Gamedev forum code... It fails to insert a newline after a compiler directive even though the OP put it there...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!