Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Test bitfields with unnamed union
//clang 3.7.0 #include <iostream> typedef struct bitfield { unsigned int a:16; unsigned int b:17; union u { unsigned int c:4; unsigned int d:32; }U; }bfield; typedef struct bitfield2 { unsigned int a:16; unsigned int b:17; union { unsigned int c:4; unsigned int d:32; }; }bfield2; int main() { std::cout << "Test bitfields1\n" << sizeof(bfield) << "\n"; std::cout << "Test bitfields2\n" << sizeof(bfield2) << "\n"; static volatile bfield y; y.a=0x1234; y.b = 0x1FF55; y.U.d = 0x5a5a5a5a; std::cout << std::hex << y.U.d << "\n"; static volatile bfield2 x; x.a=0x1234; x.b = 0x1FF55; x.d = 0x5a5a5a5a; std::cout << std::hex << x.d << "\n"; }
run
|
edit
|
history
|
help
0
Calculate H.C.F using recursion
Last Class Quiz - Working with Hash Table
DESim Example with Hash Table
Reference example
Class operator overloading the subscript and boundary check for array
Enum flags operator example
std::99 bottles of beer!
Alternation regex
C++ Standard Template Library
SceneGraph Interviewee Task