I learned that in C++, int main() can be left without a return-statement, at which point it defaults to returning 0.
I am wondering if this is also true in C? Would the program cause an error if the function definition is int main()
, but its body doesn't contain a return statement?
Asked
Active
Viewed 34 times
0

Claire
- 167
- 4
-
1Did you look in the standard? This is your first stop on questions like this. – the busybee Apr 30 '21 at 16:17
-
1Since the C99 standard the [`main`](https://en.cppreference.com/w/c/language/main_function) function in C have the same behavior. – Some programmer dude Apr 30 '21 at 16:17
-
1see https://en.cppreference.com/w/c/language/main_function and bookmark that site for other questions you may have. – JDługosz Apr 30 '21 at 16:19