return
exits from the function while exit
exits from the program.
In main
function executing return 0;
statement or calling exit(0)
function will call the registered atexit
handlers and will cause program termination.
source - http://stackoverflow.com/questions/17383015/difference-between-return-0-and-exit-0
- return is an instruction of the language that returns from a function call.
- exit is a system call (not a language statement) that terminates the current process.
The only case when both do the same thing is in the main()
function, as a return from main performs an exit()
.
source - http://stackoverflow.com/questions/3463551/what-is-the-difference-between-exit-and-return
'Development > C' 카테고리의 다른 글
c - waitpid() 함수 (0) | 2013.11.03 |
---|---|
c - execlp() 함수 (0) | 2013.11.03 |
c - pid_t (0) | 2013.11.03 |
c - 메모리 맵(memory map) (1) | 2013.08.30 |
c - 구조체 (0) | 2013.04.26 |