atoi() 函数
来源:互联网 发布:矩阵分解 als 编辑:程序博客网 时间:2024/05/01 12:10
atoiC语言库函数名
atoi
atoi原型:
int atoi(const char *nptr);
atoi函数说明
atoi( ) 函数会扫描参数 nptr字符串,跳过前面的空白字符(例如空格,tab缩进等,可以通过isspace( )函数来检测),直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果返回。如果 nptr不能转换成 int 或者 nptr为空字符串,那么将返回 0
atoi例子:
编辑(1)
1
2
3
4
5
6
7
8
9
10
11
12
//vs2013里调用printf函数请使用预处理命令#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
int
main(
void
)
{
int
n;
char
*str =
"12345.67"
;
n =
atoi
(str);
printf
(
"int=%d\n"
,n);
return
0;
}
输出:
int = 12345
(2)
1
2
3
4
5
6
7
8
9
10
11
12
13
//vs2013里调用printf函数请使用预处理命令#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
int
main()
{
char
a[] =
"-100"
;
char
b[] =
"123"
;
int
c;
c =
atoi
(a) +
atoi
(b);
printf
(
"c=%d\n"
, c);
return
0;
}
执行结果:
c = 23
0 0
- atoi函数
- atoi函数
- atoi () 函数
- atoi函数
- atoi()函数
- atoi 函数
- atoi函数
- atoi函数
- atoi函数
- atoi函数
- atoi函数
- atoi函数
- atoi函数
- atoi()函数
- atoi函数
- atoi函数
- atoi()函数
- atoi函数
- java最基本实现文件上传的过程
- Eclipse启动Tomcat服务器成功,浏览器访问出现404
- Volley 图片缩放逻辑
- new(std::nothrow)
- jar包冲突那些事,编译器不报错,启动报错
- atoi() 函数
- Android实验之实现一个生日备忘簿
- 【iOS沉思录】深思Objective-C中的property属性
- Python缩进问题
- 初步学习opencv的几个程序示例 学习笔记
- leetcode 405. Convert a Number to Hexadecimal
- 从头开始学习yii2---4.对于布局文件的理解
- hdu3853(概率与期望dp入门)
- 递归与尾递归