Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. int main (int argc, char *argv[])
  6. {
  7.  
  8.     if ( argc!=2 )
  9.     {
  10.         fprintf(stderr,"Usage : script <tailleBuffer>");
  11.         exit(1);
  12.     }
  13.  
  14.     int tailleBuf = atoi(argv[1]);
  15.     int c;
  16.    
  17.     unsigned char* buffer = ( unsigned char* ) malloc(tailleBuf*sizeof( unsigned char ));
  18.    
  19.     while((c = read(0,buffer,tailleBuf)) > 0)
  20.     {
  21.         write(1,buffer,c);
  22.     }
  23.     free(buffer);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement