-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_base_10.c
34 lines (31 loc) · 1.15 KB
/
ft_base_10.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_base_10.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thifranc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/12 15:29:20 by thifranc #+# #+# */
/* Updated: 2016/03/12 15:34:39 by thifranc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_base_10(char *str, char *base)
{
int i;
int n;
int out;
i = 0;
out = 0;
while (str[i])
{
n = 0;
while (base[n] != str[i] && base[n])
n++;
if (base[n] == '\0')
return (-1);
out = out * (int)ft_strlen(base) + n;
i++;
}
return (out);
}