#include<iostream>
#include<string>
using namespace std;
int ai(const char *p){
bool negflag = false;
int rs = 0;
if(*p=='+'||*p=='-'){
negflag=(*p=='-');
p++;
}
while(isdigit(*p)){
rs=rs*10+(*p-'0');
p++;
}
if(negflag) rs=0-rs;
return rs;
}
void main(){
const char a[] ="123";
int k;
k=ai(a);
cout<<k;
system("pause");
}
atoi函数编写
最新推荐文章于 2022-10-19 14:41:23 发布