Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 643095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:14:44+00:00 2026-05-13T21:14:44+00:00

This is likely a stupid question but I always find myself wondering which is

  • 0

This is likely a stupid question but I always find myself wondering which is the standard.

In most (not to say all) C++ first examples you may see the main function returning 0 value. This means the operation went ok or not?

  • 0 –> OK
  • 1 –> No OK.
  • Other –> ?

Which is the standard way of doing it?

By the way, is it better to return an integer or a boolean in this case?

Thank you guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:14:44+00:00Added an answer on May 13, 2026 at 9:14 pm

    0 or EXIT_SUCCESS means success. EXIT_FAILURE means failure. Any other value is implementation defined, and is not guaranteed to be supported. In particular, std::exit(1) or return 1; are not actually guaranteed to indicate failure, although on most common systems they will.

    EXIT_SUCCESS and EXIT_FAILURE are defined in <cstdlib>.

    Edit: I suppose it might be useful to give a system-specific example:

    The GNU make utility returns an exit status to the operating system:

    • 0: The exit status is zero if make is successful.
    • 2: The exit status is two if make encounters any errors. It will print messages describing the particular errors.
    • 1: The exit status is one if you use the `-q’ flag and make determines that some target is not already up to date.

    The ability to set multiple different values of failure means you can specify exactly how your program failed. There are two caveats, however:

    • There is no convention for failure status codes, afaik
    • This will work on “normal” OSes (windows, os x, unix), but it’s not guaranteed by the C++ standard; so it might not work if you tried porting to VMS or some embedded system.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is most likely a stupid question but regarding Amazon EC2 Pricing are the
I am aware this is most likely a very stupid question, but I just
Ok so this is likely a ridiculously stupid question but I can't seem to
This is most likely not an easy one but here is the situation: I
I know this is most-likely a simple question but when you restore a database
I think this is likely to be a generic .NET assembly loading question, but
,This question is likely subjective, but a lot of grid Javascript plugins have come
Sorry if this is a stupid question but sometimes I see Easter eggs and
I have this ajax call, which works for the most part, but it does
I am pretty sure this is a stupid question, but here goes anyway. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.