home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / edlib.lzh / EDLIB / HEXTOINT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-16  |  527 b   |  24 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6.  
  7. /* this function takes a string of hex digits and returns its value */
  8. #include <ctype.h>
  9.  
  10. int hextoint(number)
  11. register char *number;
  12. {
  13.     register int value = 0;
  14.  
  15.     while ( *number )
  16.         if ( isxdigit(*number) ) {
  17.             value = ( value << 4 )  + toint(*number++);
  18.         } else {
  19.             return(value);
  20.         }
  21.  
  22.     return(value);
  23. }
  24.