Term
|
Definition
| A grouping of data, usually of different types |
|
|
Term
|
Definition
|
|
Term
| Why can't a struct contain itself? |
|
Definition
| The compiler needs to know how big the struct is at compile-time, it can't just wait and deal with it at runtime |
|
|
Term
| Why can't you initialize a struct's pointer data member with dot notation? |
|
Definition
| It is telling the pointer to point at something else, then you lose the thing it was pointing at |
|
|
Term
| How to initialize a struct's character array? |
|
Definition
| strcpy(matthew.first_name, "matthew") |
|
|
Term
| Why do we use arrow notation with a struct pointer? |
|
Definition
| The struct pointer must be dereferenced (to a struct) before its data members can be accessed |
|
|
Term
| Are structs passed by value or by reference? |
|
Definition
|
|
Term
| Why is it faster to pass a struct pointer into a function than a struct? |
|
Definition
| Structs are passed by value, so a copy of the struct is made. Returning a struct also makes a copy. |
|
|
Term
| When does it make sense to forward declare a struct? |
|
Definition
| When declaring a pointer to the struct or functions that take the struct as a parameter |
|
|
Term
|
Definition
| A struct that allocates a certain predetermined number of bits to each data member |
|
|
Term
|
Definition
| Hardware devices that use bits as on/off switches, like a smart thermostat |
|
|
Term
| Will sizeof() work for bitfields? |
|
Definition
| No, sizeof() is for bytes, not bits |
|
|
Term
|
Definition
| Like a struct, but it only stores a single member at a time. When you set one data member, it overwrites the one you last set. |
|
|
Term
|
Definition
| The size of its largest data member |
|
|
Term
|
Definition
| You want to store something, but it could be any different type |
|
|
Term
| How are structs stored in memory? |
|
Definition
| The data members are stored in memory as they are written, the same as if you had just declared the members outside of the struct. But the compiler can rearrange them! |
|
|