Re: Converting a character array to single hex value



Michael Mair wrote:
Nils O. Selåsdal wrote:
nikNjegovan@xxxxxxxxx wrote:

so the idea is if the array is

[  '2','0','3','1','.','0','0'  ]

then the output of the conversion would be

07EF (I'm not interested in the decimal and it can be truncated)

If you can convert that to an integer, you can format it as you like using printf/sprintf.

char foo[] = "2031.00";
<snip>

The OP's first post specifically wanted foo to be
 char foo[7] = {'2','0','3','1','.','0','0'};

I didn't see that requirement specifically set, and even if it was, why not add an extra element to the not-overly-large array and add a nul terminator after he read the characters from his uart for simplicity ? .



Relevant Pages

  • How to create Word Processing from scratch?
    ... This my first post and question. ... Handling unicode char in editing view (editing view is object that ... Handling unicode char/string in copy, cut, and paste operation. ... Can I view all char in a specify font? ...
    (microsoft.public.vc.language)
  • Re: Convert an ip address to long value
    ... Michael Mair wrote: ... >> in the string char *ip to its long value equivalent. ... >> int main{ ... > if (err) { ...
    (comp.lang.c)
  • Re: Hi all from Char and Lyn
    ... Thanks for the update on you both...I think of and miss Char a bunch... ... She was the first person to answer my very first post to ASA and made me ... the foibles of Google to post for herself. ...
    (alt.support.arthritis)
  • Re: newbie - Prolog, lists, recursion
    ... This is an extension of my first post ... ... I can't think how to "loop" over the number char by char, ... with assignments are frowned upon - these q's are not assignments. ...
    (comp.lang.prolog)
  • Re: Confusion with stdarg
    ... Michael Mair wrote: ... Variable arguments of vararg functions get promoted, ... > cannot pass just a char but will always get an int. ...
    (comp.lang.c)