What does enum status : unsigned char { OK, FAIL }; do in C23?
C23 lets you choose the integer type behind an enum. The size becomes predictable (1 byte here), which matters for binary formats; values outside the type's range are errors.
Structures, Unions, Enums · Exercise 1 of 4
Twelve multiple-choice questions on structures, unions and enums – including padding, flexible array members, bit-fields, anonymous members (C11) and C23 enums. Pick an option to check your answer instantly.
What does enum status : unsigned char { OK, FAIL }; do in C23?
C23 lets you choose the integer type behind an enum. The size becomes predictable (1 byte here), which matters for binary formats; values outside the type's range are errors.
Why must a linked-list node be declared as struct node { int v; struct node *next; }; and not with struct node next;?
Inside its own definition the struct is still an incomplete type: its size is unknown, so it cannot be a member. A pointer has a known size, so struct node *next is fine.
Timed online tests with instant scores and explanations.