C Programming Practice Test: Structures, Unions and Bit-Fields — Flashcards | C Programming | FatSkills

C Programming Practice Test: Structures, Unions and Bit-Fields — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

Quiz questions on: Structures basics, functions, arrays of structures, pointer to structires, self referential structures, table lookup, typedefs, unions and bit fields.

Structures: A structure is a user-defined data type that allows you to group together related data items. For example, you could create a structure to store information about a person, such as their name, age, and address.
To declare a structure, you use the struct keyword followed by the name of the structure and a list of its members. Each member of a structure must have a type and a name. Once you have declared a structure, you can create variables of that type. 

Unions: A union is a user-defined data type that allows you to store different types of data in the same memory location. This can be useful for saving memory or for accessing data in different ways. To declare a union, you use the union keyword followed by the name of the union and a list of its members. Each member of a union must have a different type.

Once you have declared a union, you can create variables of that type. To do this, you use the union keyword followed by the name of the union and the name of the variable.
You can access the members of a union using the dot operator. However, you can only access one member of a union at a time. If you try to access a member of a union that has not been initialized, the behavior is undefined.

Bit-Fields: A bit-field is a data type that allows you to store a small number of bits in a single memory location. This can be useful for saving memory or for accessing data in a specific way. Once you have declared a bit-field, you can create variables of that type. 

1 of 143 Ready
Which of the following are themselves a collection of different data types?
structures
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password