gpt4 book ai didi

c - 为什么退出(42)?

转载 作者:行者123 更新时间:2023-12-04 10:39:15 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





What is the origin of magic number 42, indispensable in coding? [closed]

(6 个回答)


5年前关闭。




为什么我们在退出进程时使用 42 作为 exit 的参数?我想知道它是一些宏值(比如 1 是 EXIT_FAILURE 宏的值)还是有更深层次的含义?

if(pid == 0) {
printf("something\n");
exit(42);
}

很明显,我使用 exit(1) 还是 exit(42) 并不重要,但为什么只使用 42?

最佳答案

除了 0 之外的任何数字都可以。但是 42 是 Answer to the Ultimate Question of Life, the Universe, and Everything .

很受IT人士的欢迎...

但为什么道格拉斯亚当斯选择了 42?

I sat at my desk, stared into the garden and thought '42 will do'. I typed it out. End of story

关于c - 为什么退出(42)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39366400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com