You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
363 B
26 lines
363 B
int my_atoi(char *str)
|
|
{
|
|
int i;
|
|
int posi;
|
|
int num;
|
|
|
|
i = 0;
|
|
posi = 1;
|
|
num = 0;
|
|
while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13))
|
|
i++;
|
|
while (str[i] == '-' || str[i] == '+')
|
|
{
|
|
if (str[i] == '-')
|
|
posi = posi * -1;
|
|
i++;
|
|
}
|
|
while (str[i] >= 48 && str[i] <= 57)
|
|
{
|
|
num = num * 10;
|
|
num = num + (str[i] - 48);
|
|
i++;
|
|
}
|
|
return (num * posi);
|
|
}
|