-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lputnbr_fd.c
31 lines (28 loc) · 1.26 KB
/
ft_lputnbr_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
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lputnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jovicto2 <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/24 19:08:06 by jovicto2 #+# #+# */
/* Updated: 2023/06/24 19:14:22 by jovicto2 ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/libft.h"
size_t ft_lputnbr_fd(long nbr, int fd)
{
size_t written_bytes;
char converter;
written_bytes = 0;
if (nbr < 0)
{
nbr = -nbr;
written_bytes += write(fd, "-", sizeof(char));
}
if (nbr / 10 > 0)
written_bytes += ft_lputnbr_fd(nbr / 10, fd);
converter = nbr % 10 + '0';
written_bytes += write(fd, &converter, sizeof(char));
return (written_bytes);
}