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
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#include "libftprintf.h"
|
|
|
|
|
|
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
|
|
|
{
|
2022-04-15 00:15:26 +02:00
|
|
|
int ret;
|
2022-04-15 20:55:58 +02:00
|
|
|
long l;
|
2022-04-15 00:15:26 +02:00
|
|
|
char *s;
|
2022-04-26 17:53:39 +02:00
|
|
|
char c;
|
2022-04-15 00:15:26 +02:00
|
|
|
|
2022-04-26 17:53:39 +02:00
|
|
|
ret = 0;
|
2022-04-15 20:55:58 +02:00
|
|
|
l = va_arg(ap, long);
|
2022-04-26 17:53:39 +02:00
|
|
|
c = *format;
|
|
|
|
|
if (c == 'x')
|
2022-04-29 11:00:53 +02:00
|
|
|
s = ft_ltoa_base(l, HEXA_LOWER);
|
2022-04-15 00:15:26 +02:00
|
|
|
else
|
2022-04-29 11:00:53 +02:00
|
|
|
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);
|
2022-04-15 00:15:26 +02:00
|
|
|
free(s);
|
|
|
|
|
return (ret);
|
2022-04-13 08:01:46 +02:00
|
|
|
}
|