Advertisement
Coriic

Untitled

Mar 14th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. static void print_content(char* name){
  2.     char c;
  3.     char buffer[BUFFER_SIZE];
  4.     struct aiocb my_aio;
  5.     int file, nread;
  6.     printf("Print content? [y/n]: ");
  7.     c = getchar();
  8.     if(c == 'y'){
  9.         file = open(name, O_RDONLY);
  10.         memset(&my_aio, 0, sizeof(struct aiocb));
  11.         my_aio.aio_nbytes = BUFFER_SIZE;
  12.         my_aio.aio_fildes = file;
  13.         my_aio.aio_offset = 0;
  14.         my_aio.aio_buf = buffer;
  15.         aio_read(&my_aio);
  16.         while(aio_error(&my_aio) == EINPROGRESS){
  17.         }
  18.         printf("%s", (char*)my_aio.aio_buf);
  19.         close(file);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement