On February 5, 2009 10:58, in comp.lang.c, alessio211734
(
[email protected]) wrote:
[snip]
I want a array of unsigned byte as you tell is show as a string of hex
values.
unsigned char msg[10]={10,11,12,255} should be show as a char msgresult
[200]="0A 0B 0C 255"
OK. There is no "easy, one step" way to do this in standard C (there /may/
be 3rd-party extensions that do this, but I don't know what they are).
However, this is a very simple matter of programming, easily accomplished
with standard C tools. And, any programmer beyond "casual newbie" level
should be able to figure this out without help. I'll even give you some
hints:
1) Tell me how you would convert /one/ char value to a hex string
representation.
2) Tell me how you would determine the number of char values in your array,
3) Combine these two things together, with whatever 'glue' code you need, to
create a hex representational string of the multiple char values found in
the array.
4) you are done.
I'll even tell you some standard C operators and functions that will help:
sizeof to determine the size (if not already known) of your array
for () { } to iterate through your array
sprintf() to generate a hex representation string from one char value
strcat() to concatinate strings together
malloc() to allocate a working buffer for strings and such
printf() to print your hex representational string (optional)
Now, show us your code.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------