int StrToInt( char str[]) {
bool bFlagNeative =false;
if( str[0] == '-') {
bFlagNeative =true;
}
int i=0;
int num =0;
while(str[i] != '\0') {
num *=10;
num+= (str[i++] - '0');
}
if(bFlagNeative)
num *= -1;
return num;
}
No comments:
Post a Comment