-2

I have an input file that has 16 bit int addresses. For each entry in the list, I need to read in 8 bits for a "page number", and 8 bits for an "offset". Any idea how I could do this? I don't find any support for doing bitwise operations in c.

1 Answers1

2

Read your text file into an array of 16-bit elements, and then separate the high and the low portions like this:

uint16_t num;
uint8_t low = num & 0xFF;
uint8_t high = (num >> 8) & 0xFF;
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523