pf_c.c 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* pf_c.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/02/27 01:58:26 by bchanot #+# #+# */
  9. /* Updated: 2016/03/19 03:42:30 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libftprintf.h"
  13. int pf_c(va_list ap, t_inf inf)
  14. {
  15. int nb;
  16. int len;
  17. len = 1;
  18. if (inf.l)
  19. return (pf_c_up(ap, inf));
  20. nb = va_arg(ap, int);
  21. if (inf.width > 0 && inf.min == 0)
  22. while (len++ < inf.width)
  23. ft_putchar_fd((inf.zero == 0 ? ' ' : '0'), inf.fd);
  24. ft_putchar_fd(nb, inf.fd);
  25. if (inf.width > 0 && inf.min == 1)
  26. while (len++ < inf.width)
  27. ft_putchar_fd(' ', inf.fd);
  28. return (inf.width > 0 ? inf.width : 1);
  29. }