fork download
  1. /* main program illustrating the UNIX fork() system call.
  2. Compile using cc -o main main.c
  3. */
  4. #include <stdio.h>
  5. int main()
  6. {
  7. int i = 0;
  8. int cnt = 10;
  9. for (; i<3; i++){
  10. if (fork() == 0)
  11. cnt += 10;
  12. printf("+\n");
  13. printf(" %d\n ",cnt);
  14. }
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
+
 10
 +
 10
 +
 10
 +
 10
 +
 10
 +
 20
 +
 10
 +
 20
 +
 20
 +
 20
 +
 20
 +
 20