'What is the different between I put return 0 or don't put on the program
#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.
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dietrich Epp |
