? ? 原型:int? atoi?(const? char? *nptr)
??? 用法:#include? <stdlib.h>
??? 功能:將字符串轉換成整型數;atoi()會掃描參數nptr字符串,跳過前面的空格字符,直到遇上數字或正負號才開始做轉換,而再遇到非數字或字符串時('\0')才結束轉化,并將結果返回。
??? 說明:atoi()函數返回轉換后的整型數。
??? 舉例:
#include?<stdio.h>??
#include?<stdlib.h>??
??
int?main()??
{??
????char?a[]?=?"-100";??
????char?b[]?=?"456";??
????int?c?=?0;??
??????
????c?=?atoi(a)?+?atoi(b);??
??????
????printf("c?=?%d\n",c);??
}
?
結果:c = 356