why do we write int main and return 0 while we can just use void like java?
2. why doesnt gcc give error if i dont add a return statement inside main function?
You don't actually have to write return 0; in case of main function (it is the only function where it's allowed and zero will be returned if you don't do explicit return). Also MSVC, if I recall correcy, allows to write void main, but that's not by the standard, and I would use int main even there for consistency and portability.
Обсуждают сегодня