长夜漫漫,无心睡眠,大家一起学习喔!!!- int my_atoi(char *s)
- {
- int f = 1;
- int num = 0;
- char *ptr = s;
- while(isspace(*ptr))
- ptr++;
- if(*ptr == '-')
- f = -1;
- if(*ptr=='-' || *ptr=='+')
- ptr++;
- while(*ptr>='0' && *ptr<='9')
- {
- num = num * 10 + (*ptr-'0');
- ptr++;
- }
- return f*num;
- }
复制代码
|
|