Example #1
0
void	ft_putnbr_fd(int n, int fd)
{
	unsigned int	nb;

	nb = n;
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		nb = -1 * n;
	}
	if (nb >= 10)
	{
		ft_putnbr_fd(nb / 10, fd);
		ft_putnbr_fd(nb % 10, fd);
	}
	else
		ft_putchar_fd(nb + 48, fd);
}
Example #2
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n == 0)
		ft_putchar_fd('0', fd);
	if (n == -2147483648)
		ft_putstr_fd("-2147483648", fd);
	if (n && n >= -2147483647 && n <= 2147483647)
	{
		if (n < 0)
		{
			ft_putchar_fd('-', fd);
			n = -n;
		}
		if (n >= 10)
			ft_putnbr_fd((n / 10), fd);
		ft_putchar_fd(((n % 10) + '0'), fd);
	}
}
Example #3
0
void	ft_putnbr_fd(int n, int fd)
{
	unsigned int	n2;

	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n2 = -n;
	}
	else
		n2 = n;
	if (n2 >= 10)
	{
		ft_putnbr_fd(n2 / 10, fd);
		ft_putnbr_fd(n2 % 10, fd);
	}
	else
		ft_putchar_fd(n2 + '0', fd);
}
Example #4
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n == -2147483648)
		ft_putstr_fd("-2147483648", fd);
	else if (n < 0)
	{
		ft_putstr_fd("-", fd);
		ft_putnbr_fd(n * -1, fd);
	}
	else if (n == 0)
		ft_putstr_fd("0", fd);
	else if (n >= 10)
	{
		ft_putnbr_fd(n / 10, fd);
		ft_putchar_fd(n % 10 + '0', fd);
	}
	else
		ft_putchar_fd(n % 10 + '0', fd);
}
Example #5
0
void		ft_putendl_fd(char const *str, int fd)
{
	if (str != 0)
		while (*str != '\0')
		{
			ft_putchar_fd(*str, fd);
			str++;
		}
	write(fd, "\n", 1);
}
Example #6
0
void	ft_putnbr_fd(int n, int fd)
{
	int		i;

	i = n % 10;
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n = n * (-1);
	}
	if (n < 10)
		ft_putchar_fd(n + '0', fd);
	else
	{
		n = n / 10;
		ft_putnbr_fd(n, fd);
		ft_putchar_fd(i + '0', fd);
	}
}
Example #7
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n >= 0 && n <= 9)
		ft_putchar_fd('0' + n, fd);
	else if (n > 9)
	{
		ft_putnbr_fd(n / 10, fd);
		ft_putnbr_fd(n % 10, fd);
	}
	else if (n == -2147483648)
	{
		ft_putstr_fd("-2147483648", fd);
	}
	else if (n < 0)
	{
		ft_putchar_fd('-', fd);
		ft_putnbr_fd(-n, fd);
	}
}
Example #8
0
void	ft_putstr_fd(char const *s, int fd)
{
	char	*ptr;

	if (!s)
		return;
	ptr = (char *)s;
	while (*ptr)
		ft_putchar_fd(*ptr++, fd);
}
Example #9
0
void	ft_putnbr_fd(int n, int fd)
{
	unsigned int	nb;

	if (n < 0)
	{
		nb = -n;
		ft_putchar_fd('-', fd);
	}
	else
		nb = n;
	if (nb < 10)
		ft_putchar_fd((nb + '0'), fd);
	else
	{
		ft_putnbr_fd((nb / 10), fd);
		ft_putnbr_fd((nb % 10), fd);
	}
}
Example #10
0
void	ft_putarray_fd(char **array, char sep, int fd)
{
	while (*array)
	{
		ft_putstr_fd(*array, fd);
		if ((array + 1))
			ft_putchar_fd(sep, fd);
		array++;
	}
}
Example #11
0
void	ft_putnbr_fd(int n, int fd)
{
	char	nbr;

	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n = -n;
	}
	if (n >= 10)
	{
		nbr = n % 10;
		nbr += '0';
		ft_putnbr_fd(n / 10, fd);
		ft_putchar_fd(nbr, fd);
	}
	else
		ft_putchar_fd(n + '0', fd);
}
Example #12
0
void	ft_putnbr_fd(int n, int fd)
{
	unsigned int	i;

	if (n < 0)
	{
		i = n * -1;
		ft_putchar_fd('-', fd);
	}
	else
		i = n;
	if (i < 10)
	{
		ft_putchar_fd(i + 48, fd);
		return ;
	}
	ft_putnbr_fd(i / 10, fd);
	ft_putchar_fd(i % 10 + 48, fd);
}
Example #13
0
void		ft_putnbr_fd(int n, int fd)
{
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		ft_put_aux_nbr_fd(n * -1, fd);
	}
	else
		ft_put_aux_nbr_fd(n, fd);
}
Example #14
0
static void	ft_put_aux_nbr_fd(int n, int fd)
{
	if (n >= 10)
	{
		ft_put_aux_nbr_fd(n / 10, fd);
		ft_put_aux_nbr_fd(n % 10, fd);
	}
	else
		ft_putchar_fd(n + 48, fd);
}
Example #15
0
void	log_int(char *message, int number)
{
	int		fd;

	fd = open(LOG_FILE, O_RDWR | O_APPEND);
	ft_putstr_fd(message, fd);
	ft_putnbr_fd(number, fd);
	ft_putchar_fd('\n', fd);
	close(fd);
}
Example #16
0
void	ft_putstr_fd(char const *s, int fd)
{
	if (!s)
		return ;
	while (*s)
	{
		ft_putchar_fd(*s, fd);
		s++;
	}
}
Example #17
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n == -2147483648)
	{
		write(fd, "-2147483648", 11);
	}
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n *= -1;
	}
	if (n <= 9 && n >= 0)
		ft_putchar_fd(n + '0', fd);
	else
	{
		ft_putnbr_fd(n / 10, fd);
		ft_putchar_fd(n % 10 + '0', fd);
	}
}
Example #18
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n <= 9)
		ft_putchar_fd('0' + n, fd);
	else
	{
		ft_putnbr_fd(n / 10, fd);
		ft_putnbr_fd(n % 10, fd);
	}
}
Example #19
0
void	ft_putnbr_fd(int n, int fd)
{
	unsigned int	n2;

	if (n >= 0)
		n2 = n;
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n2 = -n;
	}
	if (n2 > 9)
	{
		ft_putnbr_fd(n2 / 10, fd);
		ft_putnbr_fd(n2 % 10, fd);
	}
	if (n2 <= 9)
		ft_putchar_fd(n2 + 48, fd);
}
Example #20
0
void			ft_putnbr_fd(int n, int fd)
{
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		ft_putnbr_fd(-n, fd);
	}
	else
		ft_putnbr_neg_fd(n, fd);
}
Example #21
0
void	ft_putnbr_fd(long n, int fd)
{
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		if ((n / 10) != 0)
			ft_putnbr_fd(((n / 10) * -1), fd);
		ft_putnbr_fd(((n % 10) * -1), fd);
	}
	else if (n > 9)
	{
		ft_putnbr_fd((n / 10), fd);
		ft_putnbr_fd((n % 10), fd);
	}
	else if (n >= 0 && n <= 9)
	{
		ft_putchar_fd((n + 48), fd);
	}
}
Example #22
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n >= 10)
	{
		ft_putnbr(n / 10);
		ft_putnbr(n % 10);
	}
	else
		ft_putchar_fd(n + 48, fd);
}
Example #23
0
void	ft_putpositive_fd(int n, int fd)
{
	int		x;

	x = n;
	if (x > 0)
	{
		ft_putpositive_fd(n / 10, fd);
		ft_putchar_fd('0' + (n % 10), fd);
	}
}
Example #24
0
static void	ft_putnbrbase_fd_inner(uintmax_t nbr, char *base, size_t baselen,
				int fd)
{
	if (nbr >= baselen)
	{
		ft_putnbrbase_fd_inner(nbr / baselen, base, baselen, fd);
		ft_putnbrbase_fd_inner(nbr % baselen, base, baselen, fd);
	}
	else
		ft_putchar_fd(base[nbr], fd);
}
void	ft_putnbr_fd(int n, int fd)
{
	if (n == -2147483648)
		ft_putstr_fd("-2147483648", fd);
	else
	{
		if (n < 0)
		{
			ft_putchar_fd('-', fd);
			n *= -1;
		}
		if (n < 10)
			ft_putchar_fd(n + 48, fd);
		else if (n >= 10)
		{
			ft_putnbr_fd(n / 10, fd);
			ft_putnbr_fd (n % 10, fd);
		}
	}
}
Example #26
0
void	ft_putstr_fd(char const *s, int fd)
{
	int	i;

	i = 0;
	while (s[i])
	{
		ft_putchar_fd(s[i], fd);
		i++;
	}
}
Example #27
0
void		ft_putnbr_fd(int n, int fd)
{
	if (n == -2147483648)
	{
		ft_putstr_fd("-2147483648", fd);
		return ;
	}
	if (n < 0)
	{
		ft_putchar_fd('-', fd);
		n = -n;
	}
	if (n < 10)
		ft_putchar_fd(48 + n, fd);
	else
	{
		ft_putnbr_fd(n / 10, fd);
		ft_putnbr_fd(n % 10, fd);
	}
}
Example #28
0
void	ft_putnbr_fd(int n, int fd)
{
	if (n > -2147483648 && n <= 2147483647)
	{
		if (n < 0)
		{
			ft_putchar_fd('-', fd);
			n = -n;
		}
		if (n > 9)
		{
			ft_putnbr_fd(n / 10, fd);
			ft_putnbr_fd(n % 10, fd);
		}
		else
			ft_putchar_fd(n + '0', fd);
	}
	if (n == -2147483648)
		ft_putstr_fd("-2147483648", fd);
}
Example #29
0
void	ft_putstr_fd(char const *s, int fd)
{
	int		i;

	i = 0;
	while (s[i] != '\0')
	{
		ft_putchar_fd(s[i], fd);
		++i;
	}
}
Example #30
0
void	ft_putstr_fd(char const *s, int fd)
{
	size_t i;

	i = 0;
	while (s && i < ft_strlen(s))
	{
		ft_putchar_fd(s[i], fd);
		i++;
	}
}