"debut TD0"
This commit is contained in:
35
2019-2020/S3T_TP_06_IPC/Squelettes/imprimer.c
Normal file
35
2019-2020/S3T_TP_06_IPC/Squelettes/imprimer.c
Normal file
@@ -0,0 +1,35 @@
|
||||
///************************************************/
|
||||
///* imprimer : Ce programme illustre le principe */
|
||||
///* du partage de temps de LINUX ... */
|
||||
/**************************************************/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
void imprimer (int unNombre, char unCar)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<unNombre; i++) printf ("%c", unCar);
|
||||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int nb, res;
|
||||
assert (argc == 2);
|
||||
nb = atoi (argv[1]);
|
||||
res = fork();
|
||||
if (res == -1)
|
||||
{
|
||||
perror ("fork");
|
||||
exit (1);
|
||||
}
|
||||
if (res == 0)
|
||||
{
|
||||
imprimer (nb, '/');
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
imprimer (nb, '*');
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user