|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
C++ question (Code error)
#14923129 - 08/14/11 10:06 PM (12 years, 9 months ago) |
|
|
Hey guys I'm an absolute noob to C++ as you know and I am encountering an error on Bucky's youtube video "Buckys C++ Programming Tutorials - 3 - More on Printing Text" Basically I'm getting an error on line 8 that says " error: expected primary-expression before ';' token. Here's my code.
#include <iostream>
using namespace std;
int main() { cout << "tupac" << endl; cout << "is dead" <<; }
It works fine if I delete "cout << "is dead" <<;" But when I add in that it doesn't work for some reason.
--------------------
|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
|
Oh shit nevermind. If I add endl; after cout << "is dead" << it works.
--------------------
|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
|
It didn't tell me to do that in the tutorial though. I just tried it to see if it worked and it did. Weird.
--------------------
|
Divinity
Wanderer of Paths



Registered: 11/17/09
Posts: 2,732
Loc: Iowa
Last seen: 9 years, 8 months
|
|
Lol you solved your own question while making a thread about it
--------------------
|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
Re: C++ question (Code error) [Re: Divinity]
#14923280 - 08/14/11 10:35 PM (12 years, 9 months ago) |
|
|
Quote:
Divinity said: Lol you solved your own question while making a thread about it
yea lol. I was thinking about deleting this thread but I'd like to know from experience C++ users why when I added endl; after cout << "is dead" << it worked. It didn't tell me that on the tutorial.
--------------------
|
Divinity
Wanderer of Paths



Registered: 11/17/09
Posts: 2,732
Loc: Iowa
Last seen: 9 years, 8 months
|
|
i dunno what c+++ is or any o that jazz, but glad you solved your problem
--------------------
|
Dawks
Jolly African Potato


Registered: 06/09/10
Posts: 4,935
|
Re: C++ question (Code error) [Re: Divinity]
#14923405 - 08/14/11 11:04 PM (12 years, 9 months ago) |
|
|
Code:
cout << "is dead" <<;
The problem is:
Code:
<<;
The insertion operator is expecting something after it.
So you could have either omitted the insertion operator and ended the line with the terminator like so:
Code:
#include <iostream>
using namespace std;
int main() { cout << "tupac" << endl; cout << "is dead" << endl; }
OR you could put another modifier after the insertion operating like endl:
Code:
#include <iostream>
using namespace std;
int main() { cout << "tupac" << endl; cout << "is dead" << endl; }
endl simply tells the program to start a new line.
Edit:
You should also get into the habit of ending your main() function with return 0;
Code:
#include <iostream>
using namespace std;
int main() { cout << "tupac" << endl; cout << "is dead";
return 0; }
It's a good habit to get into.
--------------------
date ; unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; umount ; sleep
Edited by Dawks (08/14/11 11:10 PM)
|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
Re: C++ question (Code error) [Re: Dawks]
#14923501 - 08/14/11 11:28 PM (12 years, 9 months ago) |
|
|
Alright man. I'd give you 5 shrooms if I could but I opted out. How long does it take to get proficient in C++ enough to do some game programming or anything else?
--------------------
|
Dawks
Jolly African Potato


Registered: 06/09/10
Posts: 4,935
|
|
Quote:
reeferaddict69 said: Alright man. I'd give you 5 shrooms if I could but I opted out. How long does it take to get proficient in C++ enough to do some game programming or anything else?
If you enjoy programming a lot and get really into it then I think you'd probably be able to cover all the basics in under 6 months. However generally I'd say it's a good years worth mastering the concepts should be sufficiant.
Personally I love the challenge of solving puzzles, writing new intricate codes to solve tasks. If you're like this then should whizz through it in no time.
Game programming... hmm, that's tough one. There's just so many possibilities when it comes to game programming! things like 3D programing, 2d programing, database programming, interface design/scripting, mission scripting, network/multiplayer programming, AI scripting and the list goes on and on and on.
Once you've moved through your first couple of C++ books you'll pretty fluent in the language. I should be able to say to you "hey you, yeah you with face! code me up an implementation of conway's game of life" and you'd be able to whip it out fairly confidently. At that point you should probably pick up a book on OpenGL or DirectX and start reading through it. You should be coding up little games in no time at all.
So overall I'd say:
1yr (basics) -> 1yr (getting familar, messing with GUI APIs and whatnot) -> 1-2yrs (messing with graphics libraries).
Bam. Only 4 years and I'd already hire you
If this timeline sounds like a bit much don't be put off, you'll have much fun along the way and you'll most likley pick up a lot of tricks and learn another language or two. 
Edit: You'll probably be able to start pumping out some useful applications after a month or two. Challenge yourself.
--------------------
date ; unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; umount ; sleep
Edited by Dawks (08/15/11 12:04 AM)
|
cortex
[ H ] ψ = [ E ] ψ


Registered: 10/08/02
Posts: 15,171
Loc: Gedankenexperiment
|
|
Did you buy (or "acquire through totally legal digital means") that book I suggested, C++ Primer Plus?
--------------------
Signature (up to 750 characters).
|
RonaldFuckingPaul
Our Dear Leader



Registered: 10/31/07
Posts: 13,617
Loc: Straight Outta Compton
Last seen: 9 years, 9 months
|
Re: C++ question (Code error) [Re: cortex]
#14937841 - 08/17/11 03:22 PM (12 years, 8 months ago) |
|
|
Quote:
cortex said: Did you buy (or "acquire through totally legal digital means") that book I suggested, C++ Primer Plus?
Not yet. I will though after I finish the tutorial series on youtube. Are there any quality torrents of that book?
--------------------
Edited by RonaldFuckingPaul (08/17/11 03:23 PM)
|
cortex
[ H ] ψ = [ E ] ψ


Registered: 10/08/02
Posts: 15,171
Loc: Gedankenexperiment
|
|
I honestly wouldn't know, I bought it. I cannot stand ebooks, especially for texts.
I have a few on my phone that I read when I'm waiting on the bus or whatever, but I still gotta have the real thing for real stuff.
--------------------
Signature (up to 750 characters).
|
Dawks
Jolly African Potato


Registered: 06/09/10
Posts: 4,935
|
|
Quote:
reeferaddict69 said:
Quote:
cortex said: Did you buy (or "acquire through totally legal digital means") that book I suggested, C++ Primer Plus?
Not yet. I will though after I finish the tutorial series on youtube. Are there any quality torrents of that book?
You can pirate it here:
Edit: This is not a warez site
--------------------
date ; unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; umount ; sleep
|
|