HEX to DEC IMAL problemo 
Author Message
 HEX to DEC IMAL problemo

Howdy,

If one has a BYTE buffer[256] declared, which gets populated with HEX
values,how do you extract certain segments of buffer to Decimal.
e.g
buffer[10 - 16] is Hex balance.How do I get its decimal equivalent.

I've tried memcpy to char* and sscanf but can't get it to work.

Anyone got a solution?
Paul.

________________________________________________________

Name: Paul Morrissey (Business Solutions Centre, Dublin)
Phone:   +353-1-8403001 (Ireland)  VoiceMail #:14907
Direct:   +353-1-7046488 (Ireland)

________________________________________________________



Sun, 10 Oct 1999 03:00:00 GMT  
 HEX to DEC IMAL problemo

#include <string.h>
#include <stdlib.h>

#define OFFSET 10
#define LENGTH 7

unsigned long DecodeHex(const char* pszBuffer)
{
        char szHexStuff[LENGTH+1] ;
        strncpy(szHexStuff, pszBuffer + OFFSET, LENGTH)[LENGTH] = '\0' ;
        return strtoul(szHexStuff, (char**)0, 16) ;

Quote:
}



Quote:
> Howdy,

> If one has a BYTE buffer[256] declared, which gets populated with HEX
> values,how do you extract certain segments of buffer to Decimal.
> e.g
> buffer[10 - 16] is Hex balance.How do I get its decimal equivalent.

> I've tried memcpy to char* and sscanf but can't get it to work.

> Anyone got a solution?
> Paul.

> ________________________________________________________

> Name: Paul Morrissey (Business Solutions Centre, Dublin)
> Phone:   +353-1-8403001 (Ireland)  VoiceMail #:14907
> Direct:   +353-1-7046488 (Ireland)

> ________________________________________________________



Sun, 10 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. converting hex to dec (from a file)

2. hex to dec - strtol works best!!

3. Converting from hex to dec

4. Help... conversion of hex to dec

5. Text to Hex to Dec conversion

6. hex to dec function?

7. dec to hex conversions.....more

8. hex to dec

9. Convert Dec to Hex??

10. BIN HEX DEC conversions...HELP!!!!

11. #define DEC or HEX?

12. String Hex to Dec conversion.

 

 
Powered by phpBB® Forum Software