C语言标准库-atoi

2021-07-07, updated 2021-10-31

C 库函数 int atoi(const char *str) 把参数 str 所指向的字符串转换为一个整数(类型为 int 型)。 与strtol(nptr, NULL, 10);功能相似

1
2
3
4
5
6
#include <stdlib.h>

int atoi(const char *str)
long atol(const char *nptr);
long long atoll(const char *nptr);
long long atoq(const char *nptr);

atoq与atoll相同

参数

str: 要转化的字符串

返回值

成功返回对应的整数,失败返回0

words: 122 tags: C C库函数