本文共 316 字,大约阅读时间需要 1 分钟。
C 库函数 int atoi(const char *str) 把参数 str 所指向的字符串转换为一个整数(类型为 int 型)
函数原型:int atoi(const char *str); 头文件:#include <stdlib.h>//以下程序输出结果为 1#define _CRT_SECURE_NO_WARNINGS#include#include int main(){ char a[] = "-100"; char b[] = "101"; int c; c = atoi(a) + atoi(b); printf("c = %d\n", c); return 0;}
转载地址:http://ktxmb.baihongyu.com/