What is the simplest way to convert this string to an hexadecimal value
???
TIA.
David Excoffier <david.e...@c-s.fr> wrote in message
news:393F4CE6...@c-s.fr...
char *string, *stopstring;
string = "0xFF";
l = strtol( string, &stopstring, 16 );
Sc
Francis Clark <franci...@tangozebra.com> wrote in message
news:393f6...@nnrp1.news.uk.psi.net...
Hope it helps,
Brian Genisio
lngTempWord = 0;
for(intCharCount = 0; intCharCount < 8; intCharCount++)
{
lngTempWord = lngTempWord << 4;
lngTempWord += TranslateChar( charInString[ intStringPos ] );
intStringPos++;
}
int TranslateChar( char charIn )
{
int intCharIn = (int)charIn;
// If the character value in ASCII is between 0 and 9, subtract the 0
value
if( (intCharIn >= (int)'0') && (intCharIn <= (int)'9') )
return ( intCharIn - (int)'0');
// If the character value in ASCII is between A and F, subtract the A
value and add 10
if( (intCharIn >= (int)'A') && (intCharIn <= (int)'F') )
return ( intCharIn - (int)'A' + 10 );
// If the character value in ASCII is between a and f, subtract the a
value and add 10
if( (intCharIn >= (int)'a') && (intCharIn <= (int)'f') )
return ( intCharIn - (int)'a' + 10 );
return 0;
>Hi all.
>I have a CString containing datas in hexa. (E.g.: "FF", "C4", "D8",
>"85", ...)
>
>What is the simplest way to convert this string to an hexadecimal value
>???
>
>TIA.
>
I've always just scanf'd.
sscanf(data,"%X",&longvalue);
david