tgrekov-libft
HIVE libft Oct 2023
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: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/10/28 00:10:14 by tgrekov #+# #+# */
9/* Updated: 2023/11/04 22:47:32 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include "libft.h"
21
29void ft_putnbr_fd(int n, int fd)
30{
31 char c;
32
33 if (n == -2147483648)
34 {
35 write(fd, "-2147483648", 11);
36 return ;
37 }
38 if (n < 0)
39 {
40 write(fd, "-", 1);
41 n = -n;
42 }
43 if (n > 9)
44 ft_putnbr_fd(n / 10, fd);
45 c = n % 10 + '0';
46 write(fd, &c, 1);
47}
void ft_putnbr_fd(int n, int fd)
Converts integer n to it's ASCII representation and writes it to file descriptor fd.