We know int main()
returns 0 to OS when it terminates without error
and non-zero in case of failure.
But how will the OS identify normal(without error) or abnormal(error) termination in case of void main()
.
Asked
Active
Viewed 57 times
0

David Ranieri
- 39,972
- 7
- 52
- 94

Monimoy Ghosh
- 9
- 1
-
4Such a program is a non-conforming C program. Anything can happen if a compiler accepts such a `main` function. – R Sahu Aug 30 '16 at 05:20
-
1It won't. And therefore it is better to stick to that convention if you implement OS related functionalities. – Ely Aug 30 '16 at 05:21
-
2@RSahu however it is implementation-defined if the compiler accepts `void main`, so such a compiler would have documented behaviour – M.M Aug 30 '16 at 06:58
-
@RSahu See [this answer](http://stackoverflow.com/a/9356660/1791872) – flau Aug 30 '16 at 08:21