c语言atoi用法介绍?

如题所述

函数名: atoi
功 能: 把字符串转换成长整型数
用 法: #include <stdlib.h>
int atoi(const char *nptr);
程序例:
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
int n;
char *str = "1234";

n = atoi(str);
printf("string = %s integer = %d\n", str, n);
return 0;
}

运行结果是:
string =1234 integer=1234
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-03
  atoi是ASCII to integer 的缩写,是把字符串转换成长整型数的一种函数,应用在计算机程序和办公软件中。
  C语言库函数名
  atoi
  原型:
  int atoi(const char *nptr);
  UNICODE
  _wtoi()
  参数nptr字符串,如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。否则,返回零。