62. Status or Code Dual View

 Your task is to define a struct Status that contains an anonymous union.

  • The struct should contain:
    • An anonymous union with:
      • uint16_t code
      • A struct with:
        • uint8_t low
        • uint8_t high
    • bool ok 
       
  • The program will assign a value to code, then set ok = (code == 0), and finally print low, high, and ok.
     

Example
 Input:

258

Output:

low=2 high=1 ok=false

 

Explanation:

  • 258 = 0x0102
  • low = 0x02 = 2
  • high = 0x01 = 1
  • ok = false since code ≠ 0
     
Loading...

Input

258

Expected Output

low=2 high=1 ok=false