Please explain me about unsigned char?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sathishc58
    New Member
    • Sep 2007
    • 34

    Please explain me about unsigned char?

    Hi All

    I dont have much idea about unsigned char. I know only the range of the unsigned char i.e 0 to 255.

    I want to copy this long data into a unsigned char array

    unsigned long a=59128808

    unsigned char b[20];

    I want to copy using only memcpy and not through sprintf. I dont mind creating a pointer to long and then copying to array.

    I tried to copy but I was not successful. I am getting some wrong output.

    Anyone please write a program so that it copies and gives the proper output. Or tell me when the range exceeds how it will behave with respect to unsigned long and unsigned char.


    Thanks & Regards
    Sathish Kumar
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    What do you define as 'correct output'? When you copy the long to the same location as your char array, are you expecting to see the same number in the char array? If so, your expectation is false. Maybe you could try writing a program which would output the binary values of both your unsigned long and the contents of the unsigned char array, and compare if these are equal.

    Comment

    Working...