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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:55:55+00:00 2026-05-12T23:55:55+00:00

The C standard say: The function called at program startup is named main. The

  • 0

The C standard say:

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.

However, Kernighan & Ritchie in their second edition (the canonical ANSI C) bible just use:

main()
{
  /* taram pampam ... */

  return 0;
}

Who is right?
Does it have to do with function without return value automatic assume to be returning int in C?

  • 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-12T23:55:56+00:00Added an answer on May 12, 2026 at 11:55 pm

    Well, if you want ANSI C, then by definition the standard is right.

    In C89/C90 the int return type is implied, so the K&R definition would be acceptable.

    In C99 this is no longer the case.

    The C90 standard has the following wording (5.1.2.2.1 Program startup), which is very similar to the C99 wording (probably most significantly it uses the less strong ‘can’ instead of ‘shall’):

    The function called at program startup is named main. The implementation declares no prototype for this function. It can be defined 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[]) { /* ... */ }
    

    If they are defined, the parameters to the main function shall obey the following constraints:

    [etc. …]

    There’s nothing in that section directly about the fact that leaving off the return type will result in it defaulting to int.

    Frankly, I have a hard time finding exactly where that behavior is specified by the standard. The closest I can come is in 6.7.1 (Functions definitions) where the grammar for function definitions indicates that the ‘declaration-specifiers’ are optional, and the examples say:

    Examples:

    1. In the following:

        extern int max(int a, int b)
        {
            return a > b ? a : b;
        }
      

      extern is the storage class specifier and int is the type specifier (each of which may be omitted as those are the defaults)…

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

Sidebar

Ask A Question

Stats

  • Questions 445k
  • Answers 445k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you might be looking for the term numeronym.… May 15, 2026 at 6:52 pm
  • Editorial Team
    Editorial Team added an answer The above code does work, the key was creating a… May 15, 2026 at 6:52 pm
  • Editorial Team
    Editorial Team added an answer The reason is the same as the reason you need… May 15, 2026 at 6:52 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.