Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. // Hartmeyer Vincent
  6.  
  7.  
  8. int main (int argc, char *argv[])
  9. {
  10.  
  11. if (argc!=2)
  12. {
  13. printf("Argument requis : taille du buffer");
  14. exit(1);
  15. }
  16.  
  17. int taille=atoi(argv[1]);
  18. int c;
  19.  
  20. /*allocation du buffer*/
  21. unsigned char* buffer= (unsigned char*)malloc(taille*sizeof(unsigned char));
  22. c=read(0,buffer,taille);
  23. while(c!=0)
  24. {
  25. write(1,buffer,c);
  26. c=read(0,buffer,taille);
  27. }
  28. /*on désalloue*/
  29. free(buffer);
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement