why main has to start with int?

+1 Rohit D · November 4, 2015
why main has to start with int?
why void main(){} can't be used?
why only int type is allowed in code blocks?

Post a Reply

Replies

Oldest  Newest  Rating
+1 Jon Z. · November 5, 2015
Its a good practice to return an int to let the OS know what happened with the program.
If the program finishes successfully it returns 0, otherwise if the is an error it exits returning something else.

Technically I believe you can use void main() and don`t return anything, or simply main() and don`t return anything.
  • 1

C++

107,194 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator