Union declaration

Union declaration

A union is a type consisting of a sequence of members whose storage overlaps (as opposed to struct, which is a type consisting of a sequence of members whose storage is allocated in an ordered sequence). The value of at most one of the members can be stored in a union at any one time.

The type specifier for a union is identical to the struct type specifier except for the keyword used:

Syntax

union name(optional) { struct-declaration-list } (1)
union 登录查看完整内容