c语言

c语言atoi函数的用法是什么

小亿
127
2023-11-24 22:54:57
栏目: 编程语言
C语言开发专用服务器,限时0元免费领! 查看>>

atoi函数的用法是将一个字符串转换成整数。

它的函数原型为: int atoi(const char *str);

参数说明:

函数返回值:转换后的整数值。

使用示例:

#include <stdio.h>
#include <stdlib.h>

int main() {
    char str[10] = "12345";
    int num = atoi(str);
    printf("%d\n", num);
    return 0;
}

输出结果:

12345

注意事项:

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

相关推荐:c++ atoi函数的用法是什么

0
看了该问题的人还看了