You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
3 years ago
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
2 years ago
|
/* ft_print_nbrs.c :+: :+: :+: */
|
||
3 years ago
|
/* +:+ +:+ +:+ */
|
||
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2021/10/27 09:34:01 by narnaud #+# #+# */
|
||
|
/* Updated: 2021/12/21 10:06:28 by narnaud ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "ft_printf.h"
|
||
|
|
||
2 years ago
|
int ft_print_nbr(int n, const char *str, t_opts *opts)
|
||
3 years ago
|
{
|
||
2 years ago
|
char *nbr;
|
||
2 years ago
|
char *raw;
|
||
3 years ago
|
int ret;
|
||
|
|
||
|
(void)*str;
|
||
2 years ago
|
raw = ft_itoa(n);
|
||
2 years ago
|
nbr = int_opts_transform(n, raw, opts);
|
||
|
opts->dot = 0;
|
||
|
ret = ft_print_str(nbr, opts);
|
||
|
free(raw);
|
||
2 years ago
|
free(nbr);
|
||
3 years ago
|
return (ret);
|
||
|
}
|
||
|
|
||
2 years ago
|
int ft_print_unsign(unsigned int n, const char *str, t_opts *opts)
|
||
3 years ago
|
{
|
||
2 years ago
|
char *raw;
|
||
2 years ago
|
char *nbr;
|
||
3 years ago
|
int ret;
|
||
|
|
||
|
(void)*str;
|
||
2 years ago
|
raw = ft_utoa(n);
|
||
|
nbr = uint_opts_transform(n, raw, opts);
|
||
|
opts->dot = 0;
|
||
2 years ago
|
ret = ft_print_str(nbr, opts);
|
||
2 years ago
|
free(raw);
|
||
2 years ago
|
free(nbr);
|
||
3 years ago
|
return (ret);
|
||
|
}
|
||
|
|
||
2 years ago
|
int va_print_nbr(va_list va, const char *str, t_opts *opts)
|
||
3 years ago
|
{
|
||
2 years ago
|
return (ft_print_nbr(va_arg(va, int), str, opts));
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
int va_print_unsign(va_list va, const char *str, t_opts *opts)
|
||
3 years ago
|
{
|
||
2 years ago
|
return (ft_print_unsign(va_arg(va, unsigned int), str, opts));
|
||
3 years ago
|
}
|