我正在阅读 Head First C,它说“exit()
是唯一保证永远不会返回值并且永远不会失败的函数。”
C 中是否还有其他函数不应返回任何可能返回的内容?
为什么会这样
exit()
永远不会失败?
最佳答案
Are there other functions in C that are supposed to not return anything that might?
有点。 exec()
系列(execl
、execlp
、execve
等)将用新的进程替换当前进程。成功时可执行 - 因此,成功时永远不会返回 - 或如果失败则返回 -1(并设置 errno )。
Why is it that
exit()
never ever fails?
怎么会失败呢?没有任何东西可以阻止进程退出。
关于c - 为什么 exit() 函数在 C "never fail"中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46107011/