pf_percent.c 1.2 KB

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