Posts: 9147
Threads: 83
Joined: May 22, 2013
Reputation:
46
RE: Help me with my new website!
January 26, 2018 at 6:08 pm
(This post was last modified: January 26, 2018 at 6:10 pm by bennyboy.)
There's an error in that code. The words "hello world" are missing.
That fancy cout line in your while loop, though, that's just hacks-- I never knew you could do it like that!
Posts: 5466
Threads: 36
Joined: November 10, 2014
Reputation:
53
RE: Help me with my new website!
January 26, 2018 at 10:06 pm
(January 26, 2018 at 6:08 pm)bennyboy Wrote: There's an error in that code. The words "hello world" are missing.
That fancy cout line in your while loop, though, that's just hacks-- I never knew you could do it like that!
Yeah, it's a neat little trick. The comma operator (not to be confused by the comma separator, which is by far the most common version) evaluates the expression before the comma and discards the return value (if there is one), and then evaluates the expression after the comma and keeps the return value of that one (if there is one).
So, since cout doesn't return and simply spits things out to standard output, it will give you a prompt each loop.
Posts: 2435
Threads: 21
Joined: May 5, 2017
Reputation:
26
RE: Help me with my new website!
January 26, 2018 at 11:24 pm
(January 26, 2018 at 6:08 pm)bennyboy Wrote: There's an error in that code. The words "hello world" are missing.
That fancy cout line in your while loop, though, that's just hacks-- I never knew you could do it like that!
Gunboat Diplomat
It's amazing 'science' always seems to 'find' whatever it is funded for, and never the oppsite. Drich.
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
117
RE: Help me with my new website!
January 26, 2018 at 11:39 pm
(This post was last modified: January 26, 2018 at 11:39 pm by SteelCurtain.)
As a baby programmer who just started his first job at a medium sized company, I can tell you that, at least starting out, the most important skill you'll need is being able to look at code someone else wrote and understand what it does.
In our current sprint, I have been tasked with everything from fixing a report export formatting bug to adding a looping weather radar to a mapbox. They don't teach you about geoJSON in school lol.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Posts: 5466
Threads: 36
Joined: November 10, 2014
Reputation:
53
RE: Help me with my new website!
January 26, 2018 at 11:52 pm
Yeah, the real world definitely throws curve balls at you. If I get the thing that's potentially lined up for me after this e-commerce thing, I'll have to do a deep dive into the YouTube API.
Posts: 9147
Threads: 83
Joined: May 22, 2013
Reputation:
46
RE: Help me with my new website!
January 27, 2018 at 8:17 am
(January 26, 2018 at 11:52 pm)KevinM1 Wrote: Yeah, the real world definitely throws curve balls at you. If I get the thing that's potentially lined up for me after this e-commerce thing, I'll have to do a deep dive into the YouTube API.
The google APIs are really good. They know what they're doing.
In one afternoon, I had a user system where I could click on a google map, drop a pointer, save the pointer to my database for the user, and so on. I'm not a big fan of JSON, but I am definitely a fan of free corporate solutions that let me do cool stuff in not much more time than it takes me to figure out what I want to do.
Posts: 18503
Threads: 79
Joined: May 29, 2010
Reputation:
125
RE: Help me with my new website!
January 27, 2018 at 8:26 am
(January 26, 2018 at 6:08 pm)bennyboy Wrote: There's an error in that code. The words "hello world" are missing.
That fancy cout line in your while loop, though, that's just hacks-- I never knew you could do it like that!
Heh iostream and stdio are different. I think iostream is less thread safe than stdio.
Posts: 18503
Threads: 79
Joined: May 29, 2010
Reputation:
125
RE: Help me with my new website!
January 27, 2018 at 8:44 am
(January 26, 2018 at 10:06 pm)KevinM1 Wrote: So, since cout doesn't return and simply spits things out to standard output, it will give you a prompt each loop.
std::cout should always return the std::ostream& of itself. It is used to concatenate ostream operations like:
std:: cout << something << another_thing << one_other_thing << std::endl;
Yep, instead of adding a carriage return and line feed when cout-ing, one should use std::endl. It's more portable code and flushes the stream, making it safer, thread wise.
Lets say I have a class called LastPoet, and I wanted to overload the ostream operator to print whatever that class does into whatever cout is defined to do (usually console out). I needed to declare inside the class declaration:
friend std::ostream& operator<<(std::ostream& out, const LastPoet& obj); // that return is usefull, but not to boolean evaluation
Posts: 5466
Threads: 36
Joined: November 10, 2014
Reputation:
53
RE: Help me with my new website!
January 27, 2018 at 11:40 am
When I was learning C++ back in the day, I never got to threaded programming. The most I did were programs that highlighted the usage of various, simple data structures (linked lists, stacks, queues, that sort of thing).
So, honestly (no snark), thanks for pointing that out.
Question: I keep seeing people refer to libraries like Boost for everything from better/safer memory management to string helper functions. Is there a go-to library? Or are they all more or less equal with their own pros and cons?
Posts: 3403
Threads: 24
Joined: August 9, 2015
Reputation:
27
RE: Help me with my new website!
January 27, 2018 at 11:56 am
It's actually quite impressive, It's rare to see a site all done by hand.
I cheated and used a website builder.
I tip my hat to you.
"For the only way to eternal glory is a life lived in service of our Lord, FSM; Verily it is FSM who is the perfect being the name higher than all names, king of all kings and will bestow upon us all, one day, The great reclaiming" -The Prophet Boiardi-
Conservative trigger warning.
|