Why main function main() without data type works on gcc compiler without Error? (Not related to tutorial video)
Title
Question
I have question whenever we use int main() we have to return zero at the end and according to definition default value of main function is integer. Why it is not giving error in compilation in gcc compiler ? as it is mandatory to return zero at the end but it works properly. Even int main() also working without return(0).
C-and-Cpp Functions 09-10 min 50-60 sec
Answers:
By discipline, you must write the return statement for int main(). However, some of the recent compilers, as a special case, returns 0 from the main function by default. This is applicable only to the main function.
Login to add comment