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 6882705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:17:19+00:00 2026-05-27T05:17:19+00:00

I was just writing a quick program for calculating some things when I came

  • 0

I was just writing a quick program for calculating some things when I came across the return statement/exit statement for the C program.

I declared main() to be of type int, so I would have to put in a return of an integer, or my program would not compile correctly. However, is it acceptable to make main a Boolean or even void?

I know the standard way to create a C program is to return a value so any problems can be sorted out, among other things, but wouldn’t a Boolean work the same way? Also, could I get away with declaring it void and not having problems with the operating system still running my program after it has been terminated?

Thanks for any and all help.

  • 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-27T05:17:20+00:00Added an answer on May 27, 2026 at 5:17 am

    The C99 standard says: (§5.1.2.2.1 Program startup)

    The function called at program startup is named main. The implementation declares no
    prototype for this function. It shall be defined with a return type of int and with no
    parameters:

    int main(void) { /* ... */ }
    

    or with two parameters (referred to here as argc and argv, though any names may be
    used, as they are local to the function in which they are declared):

    int main(int argc, char *argv[]) { /* ... */ }
    

    or equivalent; or in some other implementation-defined manner.

    So in a hosted environment, int is the only valid, standard return type. Implementations can define other entry points though.

    Note that section §5.1.2.2.3 Program Termination has this:

    If the return type of the main function is a type compatible with int, a return from the
    initial call to the main function is equivalent to calling the exit function with the value
    returned by the main function as its argument; reaching the } that terminates the
    main function returns a value of 0
    . If the return type is not compatible with int, the
    termination status returned to the host environment is unspecified.

    So you omitting a return from main is legal in C99, as long as your main returns an int.
    (But previous versions of the C standard didn’t have that exception for main – returning no value (or reaching the final } without a return statement) causes “the termination status returned to the host environment [to be] undefined.”.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just writing some quick code and noticed this complier error Using the
I'm just starting out writing trying to write a simple program in C and
I'm writing a small web that just makes some animation and shows some information
Just a couple of quick questions. If I'm writing CGI programs to create web
I'm writing some quick code to try and extract data from an mp3 file
This is just a quick Question. I am writing a feature here that creates
I was just writing a quick bit of code, and I wanted to use
Just a quick question about the above subject. Basically, I'm writing a piece of
Please consider the following problem. I'm writing a quick Manipulate[] program to display a
I created a quick program in Java just to get started with the GUI-based

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.