home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 163_01 / atoi.c < prev    next >
Text File  |  1988-01-31  |  512b  |  16 lines

  1. /*
  2. ** atoi -- convert signed decimal (ASCII) string to integer
  3. */
  4. atoi(nptr)  char *nptr; {
  5.   int atoi, sign;
  6.   atoi = sign = 0;
  7.   while(*nptr == '\t' || *nptr == ' ') nptr++;
  8.   if(*nptr == '-') {
  9.     sign = 1;
  10.     nptr++;
  11.     }
  12.   while(*nptr >= '0' && *nptr <= '9') atoi = (10 * atoi) + (*nptr++ - '0');
  13.   if(sign) return -atoi;
  14.   else return atoi;
  15.   }
  16.