/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_decimal_pf.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/17 18:32:20 by fgras-ca #+# #+# */ /* Updated: 2023/03/21 15:47:12 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../ft_printf.h" int ft_decimal_pf(int c) { int count; count = 0; if (c == 0) return (write(1, "0", 1)); if (c == -2147483648) return (write(1, "-2147483648", 11)); if (c < 0) { count += write(1, "-", 1); c *= -1; } if (c >= 10) count += ft_decimal_pf(c / 10); write(1, &"0123456789"[c % 10], 1); return (count + 1); }