ft_getchar.c 1.1 KB

12345678910111213141516171819202122232425262728
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_getchar.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/06/15 18:46:16 by bchanot #+# #+# */
  9. /* Updated: 2016/11/08 11:03:34 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. #include <unistd.h>
  14. int ft_getchar_fd(int fd)
  15. {
  16. char c;
  17. if (read(fd, &c, 1) != 1)
  18. return (-1);
  19. return ((int)c);
  20. }
  21. int ft_getchar(void)
  22. {
  23. return (ft_getchar_fd(0));
  24. }