Re: help needed on coversin of an char array to an integer




"MAx" <mahesh1280@xxxxxxxxx> wrote in message
news:6f4d18ab-ae46-4064-9d51-7251a738f646@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Im kinda stuck in a project at a point where i need an array to
be converted to a
integer using some kind of math.
This board does not support functions like scanf, sscanf etc as
it does not have enough memory to hold their stack.

given a string char str[8] = {'0', '0', '0' , '1' , 'f' , 'b' ,
'c' , 'a' };
i need a function which can convert this array to an integer
( 0x0001fbca )

I assume sometimes the string will be something else? Otherwise it's rather
trivial.

Where are the hex digits coming from? If from a hex keyboard, then each
digit may already be 0 to 15 then combining to an integer value is very easy
(each digit corresponds to a 4-bit chunk).

Complete solutions have already been posted, the only tricky bit is
converting each character, 0 1 2 3 4 5 6 7 8 9 a b c d e f (and maybe A B C
D E F?) to a value 0 to 15.

--
Bart


.



Relevant Pages

  • Re: help needed on coversin of an char array to an integer
    ... Where are the hex digits coming from? ... (each digit corresponds to a 4-bit chunk). ...
    (comp.lang.c)
  • Re: clear user form after entry
    ... Sorry about any confusion these two posts may have caused... ... find the first digit that is not a zero ... problem in asking for more characters than exist, so I took a guess that ... process an array; ...
    (microsoft.public.excel.programming)
  • Re: clear user form after entry
    ... find the first digit that is not a zero ... We don't know how many characters ... process an array; ... location of the first non-zero digit within the text (which is our starting ...
    (microsoft.public.excel.programming)
  • Re: clear user form after entry
    ... find the first digit that is not a zero ... (notice that the array and listing of digits do not have a zero in them), ... We don't know how many characters ... process an array; ...
    (microsoft.public.excel.programming)
  • Re: clear user form after entry
    ... find the first digit that is not a zero ... (notice that the array and listing of digits do not have a zero in them), ... We don't know how many characters ... process an array; ...
    (microsoft.public.excel.programming)