Hi all
Happy to join this forum, hope you can help me from time to time :)
I'm and electrical engineer, and I use C program as part of my work,
at a very basic level, just to control a piece of hardware.
I now have a problem which I'm sure is very basic..for you..
I have an array of unsigned char elements, which are actually hex numbers.
Something like :
unsigned char data[BYTES]={0x3f,0x20,0xf2};
When I try to print this array with :
for(j=0;j<BYTES;j++) printf("%02X\n",data[j]);
I get :
3F
20
FFFFFFF2
Any hex number who has '1' in the msb prints with 6 'F' in the beginning.
I guess it has to do with 1 or 2's complement.
How can I get the print to be always 2 digits ?
Thanks !