-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lputbin_fd.c
26 lines (23 loc) · 1.17 KB
/
ft_lputbin_fd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lputbin_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jovicto2 <jovicto2@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/24 19:22:41 by jovicto2 #+# #+# */
/* Updated: 2023/06/24 19:22:41 by jovicto2 ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/libft.h"
size_t ft_lputbin_fd(size_t nbr, int fd)
{
size_t written_bytes;
char converter;
written_bytes = 0;
if (nbr / 2 > 0)
written_bytes += ft_lputbin_fd(nbr / 2, fd);
converter = nbr % 2 + '0';
written_bytes += write(fd, &converter, sizeof(char));
return (written_bytes);
}