c - How to work with left and right bytes of a short int? -
i have short int, 2 bytes, want output left byte file. how do this? i'm using binary functions open(), read(), write(), etc.
i shift right byte left 8 times, right byte occupies left, , right has been cleared 0's.
i apologize not showing i've tried -- i'm c noobie , cannot find how this.
you seek approach
int somenum = 0x1234; int leftbyte, rightbyte; leftbyte = (somenum >> 8) & 0xff; rightbyte = (somenum) & 0xff;
c int byte bit short
No comments:
Post a Comment