Difference in Output between printf(“\n…”) and printf(“..\n”) in Linux
谁能解释一下为什么这两个相似的代码(除了 \
位置)会导致不同的输出:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <unistd.h>
#include <sys/wait.h> #include <stdio.h> int main() |
输出:

还有这个:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <unistd.h>
#include<sys/wait.h> #include <stdio.h> int main() |
结果:

我真的找不到任何令人满意的理由来解释为什么 \
的位置的简单更改会在 fork 执行完成后父程序似乎重新启动的级别更改程序的输出。
来源:https://www.codenong.com/49096059/
