source:
CIVL/examples/languageFeatures/compoundInit1.c
| Last change on this file was 8ed8eba, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 269 bytes | |
| Line | |
|---|---|
| 1 | #include <assert.h> |
| 2 | struct Node { |
| 3 | int id; |
| 4 | union { |
| 5 | int f1; |
| 6 | double f2; |
| 7 | }; |
| 8 | union { |
| 9 | int f3; |
| 10 | float f4; |
| 11 | }; |
| 12 | }; |
| 13 | int main() { |
| 14 | struct Node node = { .id=333, .f1=444, .f2=3.14 }; |
| 15 | assert(node.id==333); |
| 16 | assert(node.f2==3.14); |
| 17 | assert(node.f3==0); |
| 18 | } |
Note:
See TracBrowser
for help on using the repository browser.
