Answer the question
In order to leave comments, you need to log in
Why do you think this code doesn't work?
#include <unistd.h>
#include <stdio.h>
int ft_atoi(char *str);
int ft_atoi(char *str)
{
int res, i, sign;
i = 0;
sign = 1;
res = 0;
if (str[0] == '-')
{
sign = -1;
i++;
}
while (str[i] >= 48 && str[i] <= 57)
{
res = res*10 + (str[i] - '0');
}
return sign*res;
}
int main(void)
{
char str[] = "23";
int rslt = ft_atoi(str);
printf("%d", rslt);
return (0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question