If so what is the reason, and the returning int value indicates wat?
Is it necessary the function main() should return int?
Collapse
X
-
Tags: None
-
If you are working with TC then no need of return 0 because default return type of main() is void i.e. it does not return value...
But under Linux platform if you are using gcc then you need to write return 0 because main() returntype is int -
-
-
The standards say main() returns an int. And the only values are supposed to 0 or 1.
main() returning a void is an old Microsoft whiz-bang not even they use anymore.
The idea is that the code that calls main() has access to the returned int but I've looked into the Microsoft OS code and they don't use the returned int at all.
The big deal is that when you return void your function cannot be used as a RVAL. If some OS you don't know about starts to use main() as an RVAL, then none of your code will run on that machine.
This is very much like dragons inside the earth swallowing your alive unless they are appeased by some ritual. Why take a chance? Just appease those dragons.Comment
Comment