-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_u.c
29 lines (26 loc) · 1.28 KB
/
get_u.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_u.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rnishimo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/03 07:38:27 by rnishimo #+# #+# */
/* Updated: 2022/01/29 21:48:31 by rnishimo ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void get_u(va_list ap, t_str *st_str)
{
unsigned int num;
const char *base = "0123456789";
const int base_size = 10;
num = va_arg(ap, unsigned int);
if (num == 0)
st_str->zero = true;
st_str->size = ft_numlen_base(num, base_size);
st_str->str = (char *)malloc(sizeof(char) * (st_str->size + 1));
if (st_str->str == NULL)
return ;
set_unsigned_number_base(st_str->str, num, base);
}