home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / actlib12.zip / STRINGS.ZIP / HEXTOSTR.C < prev    next >
C/C++ Source or Header  |  1993-02-25  |  796b  |  33 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include "strings.h"
  4. #include <stdio.h>
  5.  
  6. /***
  7.  *  Function    :  hextostr
  8.  *
  9.  *  Description :  Convert an hexadecimal flow of bytes into
  10.  *                 a string containing an hexadecimal representation.
  11.  *
  12.  *  Parameters  :  out   char *string
  13.  *                 in    char *hexa
  14.  *                 in    int  length        number of hexadecimal bytes
  15.  *
  16.  *  Return      :   0 if OK
  17.  *                 -1 on error
  18.  *
  19.  *  OS/Compiler :  All
  20.  ***/              
  21.     
  22. int hextostr( char *string, const char *hexa, int length )
  23.     
  24. {                    
  25.   while ( length-- )
  26.         { sprintf( string, "%02X", (unsigned char) *hexa++ );
  27.           string += 2;
  28.         }
  29.  
  30.   return 0;
  31. }
  32.  
  33.