libft
Loading...
Searching...
No Matches
ft_putnbr_fd.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_putnbr_fd.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/11/06 14:36:04 by tspoof #+# #+# */
9
/* Updated: 2022/11/29 14:57:03 by tspoof ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
static
void
ft_itofd(
long
num,
int
sign,
int
fd)
16
{
17
if
(num >= 10)
18
{
19
ft_itofd(num / 10, sign, fd);
20
}
21
if
(num < 10)
22
{
23
if
(sign == -1)
24
ft_putchar_fd
(
'-'
, fd);
25
}
26
ft_putchar_fd
(num % 10 +
'0'
, fd);
27
}
28
29
void
ft_putnbr_fd
(
int
n,
int
fd)
30
{
31
long
num;
32
33
num = n;
34
if
(num < 0)
35
ft_itofd(num * -1, -1, fd);
36
else
37
ft_itofd(num, 1, fd);
38
}
ft_putnbr_fd
void ft_putnbr_fd(int n, int fd)
Writes number to file.
Definition
ft_putnbr_fd.c:29
libft.h
ft_putchar_fd
void ft_putchar_fd(char c, int fd)
Writes char to file.
Definition
ft_putchar_fd.c:15
src
ft_putnbr_fd.c
Generated by
1.9.7