saving . . . saved Why main function main() without data type works on gcc compiler without Error? (Not related to tutorial video) has been deleted. Why main function main() without data type works on gcc compiler without Error? (Not related to tutorial video) has been hidden .
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 21-04-20, 11:45 a.m. zubeen

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.


21-04-20, 1:40 p.m. firuza
Ok thank you
21-04-20, 2:41 p.m. zubeen

Login to add comment


Log-in to answer to this question.