/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_atoi_base.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet 1 || str[i] == '+' || str[i] == '-') return (0); } if (i == 1) return (0); return (i); } int ft_find(char *str, char to_find) { int i; i = 0; while (str[i] != 0) { if (str[i] == to_find) return (i); i++; } return (-1); } int ft_atoi_base(char *str, char *base) { int base_size; int sign; int nbr; int i; nbr = 0; sign = 1; base_size = ft_baser(base); i = 0; if (base == 0) return (0); while (str[i] == '+' || str[i] == '-' || str[i] == ' ') if (str[i++] == '-') sign = sign * -1; while (ft_find(base, str[i]) != -1) { nbr = nbr * base_size + ft_find(base, str[i]); str++; } return (nbr * sign); } /* #include int main() { printf("%d", ft_atoi_base(" ++----10gdg", "01")); } */