Files
ft_printf/libftprintf/ft_va_decimal.c

40 lines
1.3 KiB
C
Raw Normal View History

2022-04-13 08:01:46 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
2022-04-29 15:18:54 +02:00
/* ft_va_decimal.c :+: :+: :+: */
2022-04-13 08:01:46 +02:00
/* +:+ +:+ +:+ */
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/20 11:55:02 by gbaconni #+# #+# */
2022-04-29 15:18:54 +02:00
/* Updated: 2022/04/29 14:42:04 by gbaconni ### ########.fr */
2022-04-13 08:01:46 +02:00
/* */
/* ************************************************************************** */
2022-04-29 17:50:40 +02:00
#include "ft_printf.h"
2022-04-13 08:01:46 +02:00
2022-04-29 15:18:54 +02:00
int ft_va_decimal(const char *format, va_list ap)
2022-04-13 08:01:46 +02:00
{
2022-04-17 09:59:41 +02:00
int ret;
unsigned int u;
int d;
char *s;
2022-04-26 17:53:39 +02:00
char c;
2022-04-13 08:01:46 +02:00
2022-04-26 17:53:39 +02:00
ret = 0;
c = *(format + ft_eoflags(format));
if (c == 'u')
2022-04-17 09:59:41 +02:00
{
u = va_arg(ap, unsigned int);
s = ft_ltoa_base((long) u, "0123456789");
}
else
{
d = va_arg(ap, int);
s = ft_itoa(d);
}
2022-04-29 15:18:54 +02:00
ret += ft_va_decimal_bonus(format, ap, s);
2022-04-26 17:53:39 +02:00
ret += ft_puts(s);
2022-04-13 08:01:46 +02:00
free(s);
return (ret);
}