61. ADC Result View Anonymous Union

 Your task is to define a struct AdcSample that contains an anonymous (noname) union.

  • The struct should contain:
    • uint32_t timestamp
    • An anonymous union with
      • uint16_t raw
      • A struct with:
        • uint8_t lo
        • uint8_t hi
           
  • The program will assign values to timestamp and raw, then print timestamp, lo, and hi.

     

Example
 Input:

1000 1010

Output:

ts=1000 lo=0xF2 hi=0x3

 

Explanation:

  • raw = 0x03F2 = 1010
  • lo = 0xF2 = 242
  • hi = 0x03 = 3
Loading...

Input

1000 0x03F2

Expected Output

ts=1000 lo=0xF2 hi=0x3