atoi()函数

梦想与她 提交于 2020-01-28 03:38:04

C 库函数 int atoi(const char *str) 把参数 str 所指向的字符串转换为一个整数(类型为 int 型)
函数原型:int atoi(const char *str);
头文件:#include <stdlib.h>

//以下程序输出结果为 1
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
int main()
{
	char a[] = "-100";
	char b[] = "101";
	int c;
	c = atoi(a) + atoi(b);
	printf("c = %d\n", c);
	return 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!