home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / s / smc21lib.lzh / ATOIB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  512 b   |  21 lines

  1.  
  2. #define NOCCARGC
  3. /*
  4. ** atoib(s,b) - convert s to "unsigned" integer in base b.
  5. **              Note: this is a non-standard function.
  6. */
  7. atoib(s, b) char *s; int b; {
  8.   int n, digit;
  9.   n = 0;
  10.   while(isspace(*s)) ++s;
  11.   while((digit = (127 & s++)) >= '0') {
  12.     if(digit >= 'a')  digit -= 87;
  13.     else if(digit >= 'A')   digit -= 55;
  14.     else              digit -= '0';
  15.     if(digit >= b) break;
  16.     n = b * n + digit;
  17.     }
  18.   return (n);
  19.   }
  20.  
  21.