Advertisement
DaniilWild

d12/ex00

Jul 17th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3.  
  4. void ft_putchar(int ft, char c)
  5. {
  6.     write(ft, &c, 1);
  7. }
  8.  
  9. int main(int argc, char **argv)
  10. {
  11.     int fd;
  12.     char buf[1];
  13.  
  14.     if (argc > 2)
  15.         write(1, "Too many arguments.\n", 20);
  16.     else if (argc == 1)
  17.         write(1, "File name missing.\n", 19);
  18.     else
  19.     {
  20.         fd = open(name, O_RDONLY);
  21.         while (read(fd, buf, sizeof(buf)))
  22.         {
  23.             write(1, buf, sizeof(buf));
  24.         }
  25.         close(fd);
  26.     }
  27.     return (0);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement