• TalkBass has been independent since 1998. Add your voice.
    Create a free account to reply to discussions, view embedded media, and browse with fewer display ads.
    Join freeLog in
    Want zero display ads or expanded classifieds tools? Compare plans.

Who wants to debug my C++ program

First of all... I am sooooOOoO sorry about this, but this has been boggling my mind for days, it just doens't make any damn sense. I'm having errors on all of my cout<<""<<endl; lines and on my first { after my int main... here's the program so far...


See text files in next post



I hope this shows up right. And yes, I am asking you to do my homework. ;) But I would have asked the teacher about this anyway, but she's always really busy.
 
also...

cout << " (Number of Cheeseburgers?) " << cin >> nocb;
cout << " (Number of Grilled Chicken Deluxe?) " << cin >> nogcd;
cout << " (Number of Big Macs?) " << endl << cin >> nobm;
cout << " (Number of Large French Fries?) " << endl << cin >> noff;


what the hell are you doing there?

those << should be ; ... you're not printing out a string or int that's called cin, so there should be no << there. understand?
 
after reading over your program once more I noticed more stuff...

there shouldn't be a ; after "int main() ", and you have an endl before cin, which makes the program look stupid while run.

I've gotten it all perfect and compiling well, and can post the file here if you want, but won't you rather find the errors yourself? ;)


have fun!
 
PHP:
Yup - you'll need to put the cin stuff on their own lines.

Everytime you do an operation involving "<<" with cout, the return is a reference to cout again (so the next "<<" will get sent to it too.

Doing this:

cout << "foo" << cin >> x;

is going to:

- send "foo" to cout

- send cin to cout! (not sure what this will do - if it compiles, likely it'll either print the address of cin (which is just a global variable), or some status of the object)

- try to extract from cout (not cin!) into x

But, I didn't think you could even use the >> operator on cout. That, plus the semicolon after main, makes me wonder how that program even compiles?
 
Originally posted by The_Bass
after reading over your program once more I noticed more stuff...

there shouldn't be a ; after "int main() ", and you have an endl before cin, which makes the program look stupid while run.

I've gotten it all perfect and compiling well, and can post the file here if you want, but won't you rather find the errors yourself? ;)


have fun!



You da man bassy. I might need you to post that, but I'll try and work on it myself. I did add a ; after int main() and it still said "error on line 29" which would be the {

I dunno, we'll see. I'll get back to you. Thanks again for the help and thanks for all the fish.
 
did you run that and it was fine? because I got this when I tried to compile it...

p1.cpp: In function `int main()':
p1.cpp:41: parse error before `<'

I think you know where int main() is. I tried adding a semi colon, but then several more errors popped up. :(

Line 41: cout << setw(22) << "===" << setw(12) < <"========" << setw(18) << "============" << endl;

I have no idea what's wrong with this one.
 
It compiled and ran fine for me. I used g++. There should not be a ; after int main(). Maybe the inconsistent indentation at line 41 is messing something up, though I've never used a compiler that cared about indentation. What compiler are you using?