fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main (void)
  6. {
  7. int sonPid;
  8. char string[11];
  9.  
  10. switch(fork())
  11. {
  12. case -1:
  13. printf("Erreur fork()\n"); exit(-1);
  14. case 0 :
  15. prinf("Entrez une chaine de caractères : ");
  16. scanf("%c*%c", string);
  17. sonPid = getpid();
  18. default:
  19. waitpid(sonPid);
  20. prinf("Enfant "+sonPid+" mort. Compteur = "+strlen(string));
  21. }
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, or enum expected
#include <stdio.h>
         ^
Main.java:2: error: illegal character: '#'
#include <stdlib.h>
^
Main.java:8: error: class, interface, or enum expected
    char string[11];
    ^
Main.java:10: error: class, interface, or enum expected
    switch(fork())
    ^
Main.java:13: error: class, interface, or enum expected
            printf("Erreur fork()\n"); exit(-1);
                                       ^
Main.java:14: error: class, interface, or enum expected
        case 0 :
        ^
Main.java:16: error: class, interface, or enum expected
            scanf("%c*%c", string);
            ^
Main.java:17: error: class, interface, or enum expected
            sonPid = getpid();
            ^
Main.java:18: error: class, interface, or enum expected
        default:
               ^
Main.java:20: error: class, interface, or enum expected
            prinf("Enfant "+sonPid+" mort. Compteur = "+strlen(string));
            ^
Main.java:21: error: class, interface, or enum expected
    }
    ^
12 errors
stdout
Standard output is empty