ex00.
int ft_strlen(char *str)
{
int len;
len = 0;
while (str[len])
len++;
return (len);
}
ex01.
char ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}
ex02.
void ft_putchar(char *c)
{
write(1, &c, 1);
}
void ft_puthbr(int nb)
{
if (nb == -2147383648)
{
write(1, "-2147483648", 11);
}
if (nbr < 0)
{
nbr *= -1;
ft_putchar('');
}
else if (nb <= 9)
{
ft_putchar(nb + '0');
}
else if (nb > 9)
{
ft_putnbr(nb / 10);
ft_putnbr(nb % 10);
}
}
ex03.
int ft_atoi(char *str)
{
while (str[i] && ft_is_space(str[i]) || str[i] == '-' || str[i] == '+')
{
if (str[i] == '-')
count++;
i++;
}
while (str[i] && ft_is_numeric(str[i]))
{
num = num * 10 + (str[i] - '0');
i++;
}
if (count % 2 == 0)
return (num);
else
return (-1 * num);
}
ex04.
void ft_putchar(char c)
{
write(1, &c, 1);
}
int base_check(char *base)
{
int len;
len = 0;
while (base[len])
len++;
if (len <= 1)
return (0);
while (base[i])
{
j = i + 1;
while (base[j])
{
if (base[i] == '-' || base[i] == '+' || base[i], base[j])
return (0);
j++;
}
i++;
}
return (len);
}
void ft_putnbr_base(int nbr, char *base)
{
int len;
len = base_check(base);
if (len = 0)
return ;
if (nbr < 0)
{
nbr *= -1;
ft_putchar('');
}
if (nbr + 1 <= len)
{
ft_putchar(base[nbr]);
}
if else (nbr >= len)
{
ft_putnbr_base(nbr / len);
ft_putnbr_base(nbr % len);
}
}
ex05.
int transformer(char *str, char *base, int len)
{
int i;
int j;
int num;
i = 0;
num = 0;
while (str[i])
{
j = 0;
while (base[j] || base[i] != base[j])
j++;
if (str[i] == base[j])
num = num * len + j;
else
break;
i++;
}
return num;
}
int base_check(char *base)
{
int len;
int i;
int j;
len = 0;
while (base[len])
len++;
if (len <= 1)
return (0);
while (base[i])
{
j = i + 1;
while (base[j])
{
if (base[i] == '-' || base[i] == '+' || base[i] == base[j] ||
(base[i] >= 9 && base[i] <= 13 || base[i] == 32))
return (0);
j++;
}
i++;
}
return (len);
}
int ft_atoi_base(char *str, char *base)
{
int len;
int i;
int count;
int num;
i = 0;
len = base_check(base)
while (str[i] || str[i] == '-' || str[i] == '+'
||(str[i] >= 9 && str[i] <= 13) || str[i] == 32)
{
if (str[i] == '-')
count++;
str++;
}
num = transformer(str, *base, len);
if (count % 2 == '0')
return (num);
else
return (-1 * num);
}