push_swap/libft/src/ft_printf/print_unumber.c
2024-11-04 13:11:17 +01:00

37 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: o_ :::::: ::: */
/* print_unumber.c :+: / :+::+: :+: */
/* +:+ > +:++:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
/* +#+ +#+#+ +#++#+ +#+ \o/ */
/* Created: 2024/10/27 16:32:36 by whaffman #+#+# #+#+# #+# #+# | */
/* Updated: 2024/10/27 16:32:49 by whaffman ### ### ### ### / \ */
/* */
/* ************************************************************************** */
#include <stdarg.h>
#include <unistd.h>
#include <stdlib.h>
#include "libft.h"
#include "ft_printf.h"
int print_unumber(va_list args)
{
long n;
size_t len;
char *str;
int wrote;
wrote = 0;
str = ft_calloc(sizeof(char), 12);
if (!str)
return (-1);
n = va_arg(args, unsigned int);
ft_putnbr_base(n, "0123456789", str);
len = ft_strlen(str);
wrote = write(1, str, len);
free(str);
return (wrote);
}