Link to home
Start Free TrialLog in
Avatar of zackeel
zackeel

asked on

I need a hex2str or hex2int function.


Hi,

I am in need of a function to transform hex strings (for ex: "1cf3bei4") to their
equivalent strings or unsigned long int.

Thank you.
Avatar of ozo
ozo
Flag of United States of America image

scanf("1cf3bei4","%lx",&i);
i=strtoul("1cf3bei4",(char **)NULL,16);
ASKER CERTIFIED SOLUTION
Avatar of vladimir_12345
vladimir_12345

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vladimir_12345
vladimir_12345

Hi! A little error:
use        unsigned long HexStr2Long(const char* szHexStr)
instead of          long HexStr2Long(const char* szHexStr)
 

ozo, why do you insist on posting perfectly good answers as comments?
Well, I actually seem to have made a typo of scanf for sscanf,
But I figure it's up to the questioner to determine what's a perfectly good answer,
and I'd rather err on the safe side than have a reputation of posting
perfectly poor comments as answers.
And in this case, I didn't think I could give a complete answer,
not knowing what zackeel meant by «equivalent strings» for "1cf3bei4"