atof(将字符串转换成浮点型数)
atoi(将字符串转换成整型数)
atol(将字符串转换成长整型数)
strtod(将字符串转换成浮点数)
strtol(将字符串转换成长整型数)
strtoul(将字符串转换成无符号长整型数)
toascii(将整型数转换成合法的ASCII 码字符)
toupper(将小写字母转换成大写字母)
tolower(将大写字母转换成小写字母)

 1 int atoi(const char *nptr)
 2 {
 3         int c;              /* current char */
 4         int total;         /* current total */
 5         int sign;           /* if '-', then negative, otherwise positive */
 6 
 7         /* skip whitespace */
 8         while ( isspace((int)(unsigned char)*nptr) )
 9             ++nptr;
10 
11         c = (int)(unsigned char)*nptr++;
12         sign = c;           /* save sign indication */
13         if (c == '-' || c == '+')
14             c = (int)(unsigned char)*nptr++;    /* skip sign */
15 
16         total = 0;
17 
18         while (isdigit(c)) {
19             total = 10 * total + (c - '0');     /* accumulate digit */
20             c = (int)(unsigned char)*nptr++;    /* get next char */
21         }
22 
23         if (sign == '-')
24             return -total;
25         else
26             return total;   /* return result, negated if necessary */
27 }
atoi函数源码

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-12-04
  • 2021-12-08
  • 2021-09-19
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
相关资源
相似解决方案