fork()を使用したプログラムが出力を複数回印刷することがあるのはなぜですか?
プログラム1では1 Hello world回だけ印刷されますが、削除 \nして実行すると(プログラム2)、出力が8回印刷されます。誰かが私に\nここの重要性とそれがどのように影響するかを説明してもらえますかfork()? プログラム1 #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main() { printf("hello world...\n"); fork(); fork(); fork(); } 出力1: hello world... プログラム2 #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main() { printf("hello world..."); fork(); fork(); fork(); } 出力2: hello world... hello world...hello world...hello world...hello …