On Feb 22, 12:55*am, "Bartc" <b...@freeuk.com> wrote:
> "MAx" <mahesh1...@gmail.com> wrote in message
>
> news:6f4d18ab-ae46-4064-9d51-...
>
> > 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
Hey,
Thanks guys, got the code to work. MisterE's solution did the
trick. Thanks man.
|