how to get individual bytes of an int

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • babu198649
    New Member
    • Sep 2007
    • 22

    how to get individual bytes of an int

    hi
    i have an int (which is of four bytes). i have to fetch the individual bytes of an int(ie. storing it as 4 character) .


    how to get the individual bytes of an int

    bye :)
  • manjuks
    New Member
    • Dec 2007
    • 72

    #2
    Originally posted by babu198649
    hi
    i have an int (which is of four bytes). i have to fetch the individual bytes of an int(ie. storing it as 4 character) .


    how to get the individual bytes of an int

    bye :)
    Think of bitwise operators.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Another was to look at it is that an int can be viewed as an array of 4 unsigned char. So you might try typecasting the address of the int to the address of an unsigned char. Then you can work with the bytes directly.

      Comment

      Working...