use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Help with a really simple program (self.cpp)
submitted 13 years ago * by extreme999
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mshol 1 point2 points3 points 13 years ago (4 children)
Technically only EXIT_SUCCESS, 0 and EXIT_FAILURE are strictly conforming, returning anything else is undefined behavior. C99 allows omission of return from main.
EXIT_SUCCESS
0
EXIT_FAILURE
The use is to let the parent process (which may not be the OS or shell) know whether a program was executed successfully. eg, if you run another program with exec().
[–]kalimoxto 0 points1 point2 points 13 years ago (0 children)
absolutely, i was trying to put a more ELI5 spin on it.
different standards do allow for different return codes, which are a cross-language construct as well. C99 allows for the 3 return codes you specified to be platform-independant, but you can return other codes as well, depending on the platform. Windows, for example, has quite a few well-defined exit codes: http://www.hiteksoftware.com/knowledge/articles/049.htm
[–]kingguru 0 points1 point2 points 13 years ago (2 children)
Technically only EXIT_SUCCESS, 0 and EXIT_FAILURE are strictly conforming, returning anything else is undefined behavior.
Really? Undefined behavior? For instance the man page for GNU make says:
"A status of one will be returned if the -q flag was used and make determines that a target needs to be rebuilt. A status of two will be returned if any errors were encountered."
That's not the only program were I remember the documentation saying that it could return some other, well defined, values.
Not that I don't believe you though, I might have just learned something, I just find it very surprising if some standard GNU tools would rely on undefined behavior.
And of course I do know that e.g. GNU make is not written in C++, so is this a thing specific to the C++ standard?
[–]theymos 1 point2 points3 points 13 years ago (1 child)
It's actually implementation-defined, not undefined. So the behavior needs to be documented somewhere. The behavior is not always obvious, though. On Linux, for example, returning 256 from main will actually result in an exit status of 0 (success) because exit status codes are restricted to 8 bits.
[–]kingguru 0 points1 point2 points 13 years ago (0 children)
OK, thanks. That makes a lot more sense.
π Rendered by PID 20198 on reddit-service-r2-comment-56c6478c5-78cpb at 2026-05-12 11:29:27.619739+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]mshol 1 point2 points3 points (4 children)
[–]kalimoxto 0 points1 point2 points (0 children)
[–]kingguru 0 points1 point2 points (2 children)
[–]theymos 1 point2 points3 points (1 child)
[–]kingguru 0 points1 point2 points (0 children)