Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #define taille_b 10
  6. int main(int argc, char** argv){
  7. char* invitation = "\nVeuillez entrer des caracteres :";
  8. char buffer[taille_b+1] = "\0";
  9. char message[31];
  10. int nbCar;
  11. if(write(1,invitation,strlen(invitation)) != strlen(invitation)){
  12. perror("Erreur d'ecriture");
  13. exit(10);
  14. }
  15. while(nbCar = read(0,buffer,taille_b)){
  16. if(nbCar == -1){
  17. perror("Erreur de lecture");
  18. exit(20);
  19. }
  20. if(buffer[nbCar-1] != '\n'){
  21. while(getchar() != '\n');
  22. }
  23. buffer[nbCar] = '\0';
  24. sprintf(message,"\nAppel systeme lu : %s\n",buffer);
  25. if(write(1,message,strlen(message)) != strlen(message)){
  26. perror("Erreur d'ecriture");
  27. exit(10);
  28. }
  29. if(write(1,invitation,strlen(invitation)) != strlen(invitation)){
  30. perror("Erreur d'ecriture");
  31. exit(10);
  32. }
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement