Advertisement
butbanksy

Untitled

Dec 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/signal.h>
  4. #include <fcntl.h>
  5.  
  6. main()
  7. {
  8.     int d, i, n;
  9.     int o, p;
  10.     char buf [2];
  11.     d=open ("/home/banksy/Desktop/TP2/mypipe1", O_RDWR);
  12.     if (d<0) {
  13.         printf ("Problème de lecture du pipe\n");
  14.         exit (0);
  15.     }
  16.     n=read (d, buf, 2);
  17.     printf("Affichage du contenu du pipe\n");
  18.     o=buf[0];
  19.     o=o*2;
  20.     p=buf[1];
  21.     p=p*2;
  22.     printf("Les valeurs sont %d et %d", o, p);
  23.    
  24.     printf("\n");
  25. }
  26.  
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <sys/signal.h>
  32. #include <fcntl.h>
  33. main() {
  34.     int d, i, n;
  35.     char buf [2];
  36.     d=open("/home/banksy/Desktop/TP2/mypipe1", O_RDWR| O_NDELAY);
  37.     if (d<0){
  38.         printf ("Problème d'ouverture du pipe \n");
  39.         exit (0);
  40.     }
  41.  
  42.     buf[0]=1;
  43.     buf[1]=2;
  44.     if ((n=write(d, buf, sizeof(buf)))>0) {
  45.         printf ("Ecriture effective %d\n",n);
  46.         exit (0);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement