diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-09 10:23:25 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-09 10:23:25 +0200 |
| commit | 2bc94312042100432ec332abd3c00104d0d095a2 (patch) | |
| tree | 6c60a0fde7b2d8bc984845f6a412171df977e1dc /c07/ex04 | |
| parent | 03b4d8a03fb1b2cf93aaac0dc9d317ff9c2ba705 (diff) | |
| download | piscine-2bc94312042100432ec332abd3c00104d0d095a2.tar.gz piscine-2bc94312042100432ec332abd3c00104d0d095a2.tar.bz2 piscine-2bc94312042100432ec332abd3c00104d0d095a2.zip | |
c07/c08 start, c05 faster, better, stronger
Diffstat (limited to 'c07/ex04')
| -rw-r--r-- | c07/ex04/ft_convert_base.c | 65 | ||||
| -rw-r--r-- | c07/ex04/ft_convert_base2.c | 0 |
2 files changed, 65 insertions, 0 deletions
diff --git a/c07/ex04/ft_convert_base.c b/c07/ex04/ft_convert_base.c new file mode 100644 index 0000000..f50289a --- /dev/null +++ b/c07/ex04/ft_convert_base.c @@ -0,0 +1,65 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/08 16:16:53 by cacharle #+# #+# */ +/* Updated: 2019/07/09 09:05:47 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int check_base(char *base) +{ + int i; + int j; + + i = 0; + while (base[i]) + { + if (base[i] == '-' || base[i] == '+' || base[i] == ' ' + || base[i] == '\t' || base[i] == '\n' || base[i] == '\v' + || base[i] == '\f' || base[i] == '\r') + return (0); + j = 0; + while (base[j]) + { + if (j != i && base[j] == base[i]) + return (0); + j++; + } + i++; + } + if (i < 2) + return (0); + return (1); +} + +int ft_pow(int base, int exponent) +{ + int accumulator; + + accumulator = 1; + while (exponent-- > 0) + accumulator *= base; + return (accumulator); +} + +int ft_atoi_base(char *nbr, char *base) +{ + +} + +char *ft_convert_base(char *nbr, char *base_from, char *base_to) +{ + int converted_nb; + char *converted_to + + if (!check_base(base_from) || !check_base(base_to)) + return (NULL); + converted_nb = ft_atoi_base(nbr, base_from); + printf("%d\n", convert_nb); + /*converted_to = ft_itoa_base(converted_nb, base_to);*/ + /*return (converted_to);*/ +} diff --git a/c07/ex04/ft_convert_base2.c b/c07/ex04/ft_convert_base2.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/c07/ex04/ft_convert_base2.c |
