minus and 0 flags WIP
This commit is contained in:
@@ -6,24 +6,29 @@
|
||||
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/17 12:26:23 by dgaillet #+# #+# */
|
||||
/* Updated: 2025/11/19 13:35:48 by dgaillet ### ########lyon.fr */
|
||||
/* Updated: 2025/11/19 19:56:04 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_printf_bonus.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int print_number(int nbr)
|
||||
int print_number(t_arg *arg, int nbr)
|
||||
{
|
||||
unsigned int p_nbr;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
p_nbr = nbr;
|
||||
if (nbr == 0)
|
||||
return (write(1, "0", 1));
|
||||
count += write(1, "0", 1);
|
||||
if (nbr < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
count += write(1, "-", 1);
|
||||
p_nbr = nbr * -1;
|
||||
return (1 + ft_putnbr_base(p_nbr, "0123456789", 10));
|
||||
count += print_chars(arg->zero - nbr_size_base(p_nbr, 10) - 1, '0');
|
||||
}
|
||||
return (ft_putnbr_base(nbr, "0123456789", 10));
|
||||
else
|
||||
count += print_chars(arg->zero - nbr_size_base(p_nbr, 10), '0');
|
||||
return (count + ft_putnbr_base(p_nbr, "0123456789", 10));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user