fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5.  
  6. int main() {
  7. int i;
  8.  
  9. for(i=0; i<2 ; i++) {
  10. int pid = fork();
  11. if (pid==0)
  12. {
  13. fork();
  14. printf("A\n");
  15. }
  16. else {
  17. printf("B\n");
  18. }
  19. }
  20.  
  21. printf("C\n");
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
B
B
C