1.atoi和atof的头文件 stdlib.h
另外还有的函数有:
itoa(把一整数转换为字符串 )
atol
(将字符串转换成长整型数)
atol(将字符串转换成长整型数)atol(将字符串转换成长整型数)
strtod(将字符串转换成浮点数)
strtol(将字符串转换成长整型数)
strtoul(将字符串转换成无符号长整型数)
toascii(将整型数转换成合法的ASCII 码字符)
2.atoi 调用函数:int atoi(const char* nptr);//将一个字符串转换成int型
atof 调用函数:float atof(const char* ntr) //将一个字符串转化成float型。
3.示例代码:
#include<stdio.h>
#include<stdlib.h>int main()
{
char * str = "12.34"; //int atoi(const char* nptr)
printf("the str conver to int : %d\n",atoi(str));
printf("the str conver to float : %f\n",atof(str));
printf("\n");
return 0 ;
}