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.
I'll do it for you.. I just need to get a compiler for my laptop the only thing I can think of, is that you don't have #include "<"iostream ">" (without the "s of course) in your program... edit: you also forgot a couple of ';' in there, too
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!
It's been a while since i done c++ but everything the_bass said do was correct. I can get it to compile but i get linking errors when i try to build it for some reason. Bassis
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?
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.
Actually. If you could post up your version. I'd like to compare them. As I've learned with my programming problems in the past, it's always something little and stupid I'm doing. It probably is those commas wherever they go that's screwing me over.
Thanks very much to all who contributed. I'm going to go see what I did wrong now. I'm sure this seems like child's play to you vets, but we all gotta start somewhere.
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?
I'm not sure, it's on the server that I work in. To write the program I type "joe nameofprogram.cpp" and to compile I type "c++ nameofprogram.cpp" and then I type a.out and it runs the file.
OK, I obviously did something little and stupid because I pasted yours in directly and it runs fine. I don't know WHAT I did, but I'll figure that out. Thanks again.
Here are some related products that TB members are talking about. Clicking on a product will take you to TB’s partner, Primary, where you can find links to TB discussions about these products. Browser not compatible