Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
I m just a beginner but I like return rather than exit
14th Oct 2017, 3:05 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 5
I always let it fall back to the main function, the reason is because the compiler inserts its own code before and after calling main. When main returns, destructors and some cleaning up is done, then exit is eventually called with what you returned from main.
14th Oct 2017, 6:57 AM
aklex
aklex - avatar
+ 2
Sometimes it's best to remember the simple things: exit () is a system call return is an instruction system calls tend to be expensive. Just saying.
16th Oct 2017, 1:36 AM
The Artist Formally Known as Jeremy
The Artist Formally Known as Jeremy - avatar
+ 2
i used exit sometimes but i prefer return.
16th Oct 2017, 1:04 PM
Yago Ximenes Vigano
Yago Ximenes Vigano - avatar
+ 2
use 'exit' to terminate a loop and 'return' to obtain the final value of a function.. that's according to my opinion
17th Oct 2017, 5:48 AM
Wanjiru Rose
Wanjiru Rose - avatar
+ 1
if you dont need to return but you want to exit from your program in some point what you should do?! or you need to return in your function you cant exit () you need to return. it depends where you use it. in the function or in the regular code and it depends on return type of your function.
16th Oct 2017, 1:06 AM
Murat Ahmedovich
Murat Ahmedovich - avatar
+ 1
I never use exit. But when i do WoW. lol
16th Oct 2017, 3:16 AM
Pickle_Rick()
Pickle_Rick() - avatar