fork download
  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #include <unistd.h>
  4. #include <sys/wait.h>
  5.  
  6. int x = 1;
  7.  
  8. void hit() {
  9.  
  10. printf("%d, ", x++);
  11. x += 3;
  12. }
  13.  
  14. int main() {
  15.  
  16. hit();
  17. fflush(NULL);
  18. pid_t pid = fork();
  19. if (pid > 0) {
  20. wait(NULL);
  21. hit();
  22. int x = 0;
  23. hit();
  24. printf("\b\b \r\n");
  25. } else if (pid == 0) {
  26. hit();
  27. } else {
  28. hit();
  29. printf("Fehler!\n");
  30. }
  31. return 0;
  32. }
  33.  
  34.  
Success #stdin #stdout 0.01s 5320KB
stdin
45
stdout
1, 5, 5, 9,