home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SMC21LIB.LZH / ATOIB.C < prev    next >
Text File  |  2000-06-30  |  512b  |  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.