目录一.atoi 函数二.atoi 函数函数实战 一.atoi 函数 在 stdlib.h 中 atoi 函数,可用于将 char 字符串转为 int 整数类型, 语法如下:
在 stdlib.h
中 atoi
函数,可用于将 char
字符串转为 int 整数类型,
语法如下:
int atoi(char *string);
#include "stdafx.h"
#include <stdio.h>
#include "windows.h"
#pragma warning(disable: 4996)
int _tmain(int arGC, _TCHAR* argv[])
{
printf("atoi函数计算结果 %d \n", atoi("13456"));
printf("atoi函数计算结果 %d \n", atoi("0"));
printf("atoi函数计算结果 %d \n", atoi("789"));
printf("atoi函数计算结果 %d \n", atoi("123.123")); //默认转为整数
printf("atoi函数计算结果 %d \n", atoi("-9"));
system("pause");
return 0;
}
输出:
atoi函数计算结果 13456
atoi函数计算结果 0
atoi函数计算结果 789
atoi函数计算结果 123
atoi函数计算结果 -9
请按任意键继续. . .
到此这篇关于c++中的atoi 函数简介的文章就介绍到这了,更多相关atoi 函数简介内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: C++中的atoi 函数简介
本文链接: https://www.lsjlt.com/news/158610.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0