home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / HSTR_I.C < prev    next >
C/C++ Source or Header  |  1992-04-26  |  586b  |  28 lines

  1. /*
  2. **  Originally published as part of the MicroFirm Function Library
  3. **
  4. **  Copyright 1986, S.E. Margison
  5. **  Copyright 1989, Robert B.Stout
  6. **
  7. **  Subset version released to the public domain, 1992
  8. **
  9. **  Make an ascii hexadecimal string into an integer.
  10. */
  11.  
  12. #include <stdio.h>
  13.  
  14. unsigned int hstr_i(char *cptr)
  15. {
  16.       unsigned int i, j = 0;
  17.  
  18.       while ((NULL != *cptr) && isxdigit(*cptr))
  19.       {
  20.             i = *cptr++ - '0';
  21.             if (9 < i)
  22.                   i -= 7;
  23.             j <<= 4;
  24.             j |= (i & 0x0f);
  25.       }
  26.       return(j);
  27. }
  28.