-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_bonus.c
42 lines (38 loc) · 1.37 KB
/
utils_bonus.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
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: junyojeo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/12 15:50:18 by junyojeo #+# #+# */
/* Updated: 2023/05/19 01:08:26 by junyojeo ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf_bonus.h"
void ft_puterror(char *str)
{
ft_putstr_fd(str, 1);
ft_putstr_fd("\n", 1);
exit(1);
}
int ft_atoi_base(char *str)
{
long long res;
if (*str == '\0')
return (0);
res = 0;
while ((9 <= *str && *str <= 13) || *str == 32)
str++;
while (*str)
{
if ('0' <= *str && *str <= '9')
res = res * 16 + (*str - '0');
if ('A' <= *str && *str <= 'F')
res = res * 16 + (*str - 55);
if ('a' <= *str && *str <= 'f')
res = res * 16 + (*str - 87);
str++;
}
return (res);
}