In article < .com>,
<> wrote:
:I want to scan from the following string all the hex numbers and

opulate an array of integers:
:
:0x27 0x00
:0x30 0x00
:0x33 0x00
:0x36 0x00
That doesn't look like a string to me. A string would start with
a double-quote, and would make explicit whether there are newline
characters. e.g., "0x27 0x00\n0x30 0x00\n0x33 0x00" and so on.
:How can I do so? Doing sscanf with a long list of "%x %x ..... %x" will
:do it. But is there a better way such as a loop etc.
strtoul() specifying a base of 16, and feeding the modified pointer
back in as the new initial pointer value. Look carefully at the error
conditions in the stroul() documentation -- different conditions get
signalled different ways.
You will have to decide what you want to do under various circumstances,
such as if there is only one value per line instead of two, or if
there is more than 2 values on one line, or if a string not interpretable
as hex shows up, or if a huge number shows up...
--
I don't know if there's destiny,
but there's a decision! -- Wim Wenders (WoD)