+ 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.
3 Respostas
+ 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.
+ 13
Returns 0/false to the caller of the function/method.
+ 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.