What is the different between I put return 0 or don't put on the program

Viewed 34
#include <stdio.h>
int main()
    {
        for (int  i = 0; i < 10; i++)
        {
            printf("%d",i);
        }
        
    }

I just wonder why the result of the program whether put return 0; on the code or not the result is still correct.

1 Answers

There is no difference.

According to the C standard, you can leave out return 0; on the main() function (and only that function) and it will still behave as if there is a return 0; at the end.

The exact wording in the C standard:

[…]reaching the } that terminates the main function returns a value of 0.

From n2346 §5.1.2.2.3 Program termination.

Related