Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. void        parse_instructions(int fd)
  2. {
  3.     char        *str;
  4.     int         ret;
  5.  
  6.     ft_putnbr(fd);
  7.     while ((ret = get_next_line(fd, &str)))
  8.     {
  9.         ft_putendl(str);
  10.         free(str);
  11.     }
  12. }
  13.  
  14. int         main(int ac, char **av)
  15. {
  16.     int     fd;
  17.  
  18.     if (ac > 2)
  19.     {
  20.         if (ft_strcmp(av[1], "file") == 0)
  21.         {
  22.             if ((fd = open(av[2], O_RDONLY) != -1))
  23.             {
  24.                 ft_putendl(av[2]);
  25.                 parse_instructions(fd);
  26.             }
  27.             else
  28.             {
  29.                 close(fd);
  30.                 ft_putendl("Bad file");
  31.             }
  32.         }
  33.     }
  34.     return (1);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement