Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ft_atoi(char *str)
- {
- int sign;
- size_t res;
- sign = 1;
- res = 0;
- while (((*str > 8) && (*str < 14)) || (*str == 32))
- str++;
- if (*str == '-' || *str == '+')
- {
- if (*str == '-')
- sign = -1;
- str++;
- }
- while ((*str >= '0') && (*str <= '9'))
- {
- if (res <= 9223372036854775807)
- res = (res * 10) + (*str - '0');
- else if (sign == -1)
- return (0);
- else
- return (-1);
- str++;
- }
- return (res * sign);
- }
Advertisement
Add Comment
Please, Sign In to add comment