0
Can we use void main () .... instead of int main ().
if we cannot use please tell the reason
3 Respostas
+ 2
It depends on the compiler. But the standard for main is to return an integer, so that is what you should do. The reason is that when the compiler makes the exit call, it needs to pass in an integer as a parameter, which is typically the value of what you return in main. If you use void main, the compiler will usually either give you an error or make it so the compiled code returns and exits with 0 anyways
+ 9
As of the latest standard, main() must return int to signal the OS regarding exit status.
+ 2
Another advantage to using int instead of void is that you can end the program early with the return statement.