c - exit(); is not working -


in programming book, shows me exit used without parameters(exit();). unfortunately not work.

some people have said use exit(0); while exit(1); exit(2); , exit(3); difference between them , there exit(4); ?

the funny thing compiler not need stdlib.h execute exit(0); , rest.

prior 1999 version of iso c standard, legal call function no visible declaration. compiler assume function exists, creating implicit declaration. (it assume returns result of type int, exit() not.) if implicit declaration doesn't match actual definition of function, behavior undefined.

as of 1999 standard, "implicit int" rule dropped, , call without visible declaration (as provided, in case, #include <stdlib.h>) became invalid. though it's invalid, compiler may still issue non-fatal warning , handle under older rules; gcc default.

under version of language, exit requires single argument of type int. passing 0 or exit_success (a macro defined in <stdlib.h> causes program terminate , pass status environment indicating success. passing exit_failure causes program terminate status indicating failure.

the meanings of other argument values not specified c language. you'll commonly see exit(1) denote failure, that's not entirely portable.

(exit may kind of built-in function in gcc, doesn't affect rules of language; it's still invalid call exit no visible declaration, or call without int argument. if it's built-in, might affect level of detail in diagnostic message.)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -