+ 5

What is Return 0 and when do i need to use it?

Im confused as to exactly when/how/why i need to implement this line of code.

17th Feb 2017, 3:15 PM
Noah
Noah - avatar
3 odpowiedzi
+ 14
From Bjarne Strostrup book: First it will output to the screen, and then it will return a value 0 to whoever called it. Since main() is called by system, we won't use that return value. However on systems like Unix/Linux it can be used to check whether the program succeeded. A zero returned by main() indicates the program terminated successfully.
19th Feb 2017, 1:40 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 13
Returns 0/false to the caller of the function/method.
17th Feb 2017, 3:18 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
a function needs to return something to the console, based on its type. void functions dont return anything, int functions return integers. Not always nessesary in the main function as it works even without it.
18th Feb 2017, 12:06 PM
Orfeo Terkuci
Orfeo Terkuci - avatar