What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 150 Stack Exchange communities.

The question is a little vague, so let me elaborate: I want to ask whether or not the uers of Stack Overflow include return 0 in their code even though ISO C++ doesn't require it. This doesn't really affect the code except to close out main() more clearly, but I am curious about it. Is this kind of question okay to ask on Stack Overflow?

share|improve this question
no, you cannot ask whether programmers prefer Cheetos or Doritos when they code... – quack quixote Apr 6 '10 at 1:06

4 Answers 4

up vote 9 down vote accepted

In my experience, it tends to depend on how you phrase it.

  • Do you return 0 from main()? - will almost certainly be closed.
  • Is it better to return 0 from main()? - very likely to be closed.
  • Should I always return 0 from main()? - fairly likely to be closed.
  • When should I return 0 from main()? - might stay open.
  • What are the reasons for/against returning 0 from main()? - probably will stay open.

In essence, if you're able to phrase the question in such a way that you are asking for facts as opposed to opinions, the likelihood of staying open goes up (but it still might get closed, especially if it's a dupe as gnovice has pointed out).

Disclaimer: Standards tend to vary somewhat among sub-communities on Stack Overflow, and I'm not sure how the C/C++ folks would react to these; I am pretty confident in the accuracy of these statements for the .NET/SQL groups.

share|improve this answer
This is good information. I don't really think that other question is asking the same thing, so it wouldn't really be a dupe. – Maulrus Apr 6 '10 at 0:35

It's not, because you are asking a user's opinion.

It will be closed as subjective and argumentative:
It's impossible to objectively answer this question; questions of this type are too open ended and usually lead to confrontation and argument.

share|improve this answer
yea, in theory it's correct, but in practice we have a ton of these kind of questions. Just look at the entire best-practices tag. – Earlz Apr 6 '10 at 0:22
Just because we have a ton of these questions does not make it ok – juanformoso Apr 6 '10 at 0:26
Well does that mean I can't ask any questions that could result in differing opinions? I mean, there's only two choices with return 0, and it seems like a valid best-practices question looking at the other ones on there. – Maulrus Apr 6 '10 at 0:28
try it @mau, report here the result... – juanformoso Apr 6 '10 at 0:33

It's the big huge gray area. Label it as best-practices and make it CW and it may survive though

share|improve this answer

Whether or not you should ask your question is probably a moot point, since it is already pretty much addressed by this other existing question. To summarize the answers there, there will be an implicit return 0 if you don't explicitly add it, so the inclusion or exclusion of a return statement is a subjective individual preference that doesn't appear to matter (and therefore requires no real discussion, in my opinion).

So, not only could your question get closed for being a bit too subjective, it could also be closed as a duplicate.

share|improve this answer
Eh, but that doesn't really answer my question. I understand that it's inserted by default if you don't include it, but I want to know if people /do/ include it. I've seen differing opinions on different places on the web, which I why I'm curious to see the general consensus. – Maulrus Apr 6 '10 at 0:32
@Maulrus: I think it does answer your question, because it points out that there is no real objective difference between the two different cases, and it is thus a purely subjective matter (discussions of which aren't generally welcomed on SO). – gnostradamus Apr 6 '10 at 0:39
I agree – juanformoso Apr 6 '10 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .