+ 1
What does return 0 means and why does we need to use this?
3 Respuestas
+ 16
The function has an "int" return datatype.... If you dont care about returns (but you're still forced to use return due to the return-type) you just return a random nuber like 0...
+ 3
In every C program you have to use return return 0; (or return -1;, or whatever... ), because the main function signature requires it.
In a C++ program the statement is optional: the compiler automatically adds a return 0; if you don't explicitely return a value.
The return value is the exit code of your program, the shell (or any other application that ran it) can read and use it.
The 0 exit code is a widely accepted convention for 'OK the program execution was successfull'.
taken from https://cheeze.club/2gnw