int AscToInt(const char* num){
int length = 0;
for(length; num[length] !='\0'; length++){
;
}
int k = length;
int j = 0;
if (num[0] == '+' || num[0] == '-')
j = 1;
int number = 0;
for(j; j < length; j++){
if(num[j]>'9'|| num[j]<'0')
return 0;
else if(k = length)
number += (num[j] -'0') * pow (10.00,(length-1-j));
}
if (num[0] == '-')
return 0-number;
else
return number;
}
No comments:
Post a Comment