2020-09-04 10:27:13 +02:00

36 lines
773 B
C

///************************************************/
///* 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;
}
}