fprintf
This commit is contained in:
46
lib/libft/srcs/fprintf/ft_printf_utils.c
Normal file
46
lib/libft/srcs/fprintf/ft_printf_utils.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_printf_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/28 10:42:48 by lderidde #+# #+# */
|
||||
/* Updated: 2024/11/04 09:23:14 by lderidde ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_fprintf.h"
|
||||
|
||||
int num_len(long n)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (n < 0)
|
||||
{
|
||||
n *= -1;
|
||||
i++;
|
||||
}
|
||||
while (n > 9)
|
||||
{
|
||||
n /= 10;
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
int hex_len(unsigned long num)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (num > 15)
|
||||
{
|
||||
num /= 16;
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
Reference in New Issue
Block a user