+ 1
Is there any case that allowed you to write the main function only. Ex: main ()
3 Answers
+ 6
that was allowed in early version of C and void main();, but now main is only allowed to return an int, that's why only int main(); is allowed now
+ 19
Ahmed Zakree main() is a function so it is not possible that any compiler will allow you to write a function without a return type.
There are few things which you should take note of :
1. The int is the main() function's return type. That means that main() will return an integer.
2. main( ) was tolerated by the C90 compilers but not by C99 compilers which means its not a part of C99 standard anymore, so don't do this.
3. Even void main() is not a standard form ,some compilers allow this, but none of the standards have ever listed it as an option. Therefore, compilers don't have to accept this form, and several don't. Again, stick to the standard form, and you won't run into problems if you move a program from one compiler to another.
+ 4
This is not allowed in current version.