0
int data = 0x69bd2ab7;
char byte1 = (data >> 16) & 0x000000FF;
printf("Extracted: 0x%x\n", byte1);

The above prints:

Extracted: 0xffffffbd

How do I get rid of the prepended ff's and print 0xbd?

Kat
  • 1
  • What happens if you use `int byte1` instead of `char byte1`? – Fred Larson May 01 '18 at 14:49
  • 2
    use `unsigned` types – infixed May 01 '18 at 14:50
  • @Kat, do take a look at the "possible duplicate" links - they should give you a good answer to your question. You should try to search for existing answers before asking a question but it sometimes takes a while to get the knack for choosing the right keywords to search for. Don't be discouraged if this question gets closed as a duplicate - that happens all the time. – davmac May 01 '18 at 15:04
  • Thank you, I did search but am new to stackoverflow – Kat May 01 '18 at 19:15

0 Answers0