2nd October 2019


Why is the main function an int?

The short answer, is because the C++ standard requires main() to return int . As you probably know, the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished.

Keeping this in consideration, what is the difference between return 1 and return 0?

in main function return 0 or exit(0) are same but if you write exit(0) in different function then you program will exit from that position. returning different values like return 1 or return -1 means that program is returning error . But destructors are called if return 0 is used.

What does return 0 mean in C++ programming?

Technically, in C or C++ main function has to return a value because it is declared as "int main" which means "main function should return integer data type" if main is declared like "void main", then there's no need of return 0.

What does int main () mean?

The purpose of main 's return value is to return an exit status to the operating system. In standard C, the only valid signatures for main are: int main(void) and int main(int argc, char **argv) The form you're using: int main() is an old style declaration that indicates main takes an unspecified number of arguments.
Write Your Answer


60% people found this answer useful, click to cast your vote.

3 / 5 based on 2 votes.


Press Ctrl + D to add this site to your favorites!