Files
ft_printf/libftprintf/ft_va_hexadecimal.c

34 lines
1.2 KiB
C
Raw Normal View History

2022-04-13 08:01:46 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
2022-04-29 15:18:54 +02:00
/* ft_va_hexadecimal.c :+: :+: :+: */
2022-04-13 08:01:46 +02:00
/* +:+ +:+ +:+ */
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/20 11:55:33 by gbaconni #+# #+# */
2022-04-29 15:18:54 +02:00
/* Updated: 2022/04/29 14:42:36 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_hexadecimal(const char *format, va_list ap)
2022-04-13 08:01:46 +02:00
{
int ret;
long l;
char *s;
2022-04-26 17:53:39 +02:00
char c;
2022-04-26 17:53:39 +02:00
ret = 0;
l = va_arg(ap, long);
2022-04-26 17:53:39 +02:00
c = *format;
if (c == 'x')
s = ft_ltoa_base(l, HEXA_LOWER);
else
s = ft_ltoa_base(l, HEXA_UPPER);
2022-04-29 15:18:54 +02:00
ret += ft_va_hexadecimal_bonus(format, ap, s);
2022-04-26 17:53:39 +02:00
ret += ft_puts(s);
free(s);
return (ret);
2022-04-13 08:01:46 +02:00
}