-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_set_width.c
More file actions
51 lines (46 loc) · 1.41 KB
/
ft_set_width.c
File metadata and controls
51 lines (46 loc) · 1.41 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_set_width.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aobshatk <aobshatk@mail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/29 20:46:12 by aobshatk #+# #+# */
/* Updated: 2025/01/05 21:23:23 by aobshatk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
static int num_len(int num)
{
int len;
len = 0;
while (num > 0)
{
num /= 10;
len++;
}
return (len);
}
t_flags ft_set_width(t_flags flags, char *format)
{
int num;
num = 0;
if (*format > 48 && *format <= 57)
{
num = ft_atoi((const char *)format);
flags.width = num;
format += num_len(num);
}
if (*format == '.')
{
flags.msize = 0;
format++;
if (*format >= 48 && *format <= 57)
{
num = ft_atoi((const char *)format);
flags.msize = num;
format += num_len(num);
}
}
return (flags);
}