0

what is the difference between return 0; and return 10000000; ? the code runs in the same way though any of these is applied.

7th Jan 2018, 3:54 AM
Light
Light - avatar
2 Respostas
+ 9
In main, return 10000000 and return 0 won't matter to us, but they will to the program. You see, return in main is used to return an exit code that is used by the compiler to determine whether the execution in the end was successful or not. Errors , like SIGSEGV, SIGABRT, etc, are identified by special numbers, like 255, etc. When 255 is returned, the compiler is notified that a SIGSEGV error had occurred. Thus, according to the standard, one should use 0 as 0 has been preset to be the return code for successful termination of a program.
7th Jan 2018, 4:01 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
It’s no different Is just a code word that the computer will use to say(“Hey We did it and here is the code word you told us to say if we did it correctly”)
7th Jan 2018, 4:29 AM
Someone Else
Someone Else - avatar