Autonomy Zantaz Interview Question
System Administratorsint atoi(const char *src) {
int c;
int sign;
int total;
while(isspace((int)(unsigned char)*src))
++src;
c = (int)(unsigned char)*src++;
sign = c;
if(c == '-' || c == '+')
c = (int)(unsigned char)*src++;
total = 0;
while(isdigit(c)){
total = 10 * total + (c - '0');
c = (int)(unsigned char)*src++;
}
if(sign == '-')
return -total;
return total;
}
- nomad July 06, 2011