+ 1

What does return 0 means and why does we need to use this?

6th Aug 2017, 8:09 AM
Mish T
Mish T - avatar
3 Respostas
+ 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...
6th Aug 2017, 8:10 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 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
6th Aug 2017, 8:30 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar