Examen de Programmation Système 1ère Année Informatique
Transcription
Examen de Programmation Système 1ère Année Informatique
Examen de Programmation Système 1ère Année Informatique Najib Tounsi Durée : 35 mn (30+5) Aucun document n’est autorisé Barême (1, 6, 8, 3, 2). Le temps conseillé est proprtionnel au barême. I. Expliquer le programme fork.c suivant. Quel est son résultat ? #include <stdio.h> main(){ if(fork() != 0) printf("That's all Folks\n"); else printf("Hello, World !\n"); } II. Soit prog.c le programme #include <stdio.h> main(){ printf("Hello, World !\n"); } a. Que fait le script suivant ? $ cc -o prog prog.c $ prog Soit test.c le programme #include <stdio.h> main(){ if (fork() != 0) printf("That's all Folks \n"); else execl("prog", "prog", NULL); } b. Commenter le script suivant ? $ cc test.c $ a.out That's all Folks Hello, World ! c. Quelle différence y a-t-il entre ce programme test.c et fork.c de Q1) III. Faire un programme C qui imprime « Bonjour M. ou Mme untel » selon la spécifications suivante : $ a.out Ali Bonjour M. Ali $ a.out –m Fatima Bonjour Mme Fatima IV. Soit le script : $ ls -l hello.c a.out -rwxr-xr-x 1 najib najib -rw-r--r-1 najib najib 16904 Jun 22 10:28 a.out 9 Jun 22 10:28 hello.c a. Expliquer le sens de -rw-r--r-- et de -rwxr-xr-x. $ ls -ld dir drwxr-xr-x 2 najib najib b. De même ici pour drwxr-xr-x. V. Soit Makefile un fichier qui contient prog: prog.c cc -o prog prog.c a. Que signifient ces deux lignes? b. Comment utilise-t-on ce fichier ? 68 Jun 22 10:29 dir