strtol with hex greater than 4 byte ?

From: Peter Dunker (Peter.Dunker_at_stud.tu-ilmenau.de)
Date: 04/29/04


Date: Thu, 29 Apr 2004 16:38:04 +0200

Hi,

I will check a String which should contain a HEX value.
I know that strtol is the right function for this job.

But what happens when I will check a hex string with 8 bytes?
That I can check that the string is correct i know.

long value;
char src[]="0x1234567812345678"
char *err;
value = strtol(src,&err, 16);
if (*err != 0x00)
    return -1; /*FEHLER*/

The value is not 0x12345678 but I know it is right spelled.

Is that C89 standard or only on my compiler/OS (VC6, Windows) ?

Is there a way to get the right value of the beginning of the string,
up to the sizeof(long) ?

Thx
Peter



Relevant Pages

  • injection_projection code
    ... because of hex encoding. ... a row in the template. ... Sanitize string to protect against email header injection. ... void injection_protection(char *s) ...
    (freebsd-isp)
  • Re: PCL images and mvEnterprise
    ... decimal then CHAR to get the Ascii character. ... to print the letter "A" {'A' is hex 41}, ... or by instead sending the equivalent hex pairs string ...
    (comp.databases.pick)
  • Re: How to construct a string with bunch of hex numbers?
    ... to construct a string with those hex numbers? ... No. I'd like to have a string like "xyzabc" and each ASCII char corresponds ... to a hex number. ...
    (microsoft.public.dotnet.languages.csharp)
  • Hex editor display - can this be more pythonic?
    ... I'm building a hex line editor as a first real Python programming exercise. ... I had considered using the .translatemethod of strings, however this would require a larger translation table than my printable string. ... Where printing chars are shown in parenthesis, characters with Python escape sequences will be shown as their escapes in parens., while non-printing chars with no escapes will be shown with nothing in parens. ...
    (comp.lang.python)
  • Re: Converting ascii to hex
    ... Why such meaningless and unreadable ... hex constants? ... Did you perhaps mean that "ciptmp is a CString ... For that matter, since you don't show how the string is read in, how do you know that the ...
    (microsoft.public.vc.mfc)