1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Structure members are placed next to each other in memory, similar to arrays, but alignment may cause padding.
What is the general memory layout of a structure in C?
The size of variables like a long can vary between systems, e.g., it might be 4 bytes on x86 but 8 bytes on x86_64.
How does the size of variables change between different machines?
16 bytes
What is the size of the structure struct strange with 3 integers and a character?
Padding is used to ensure that data elements in structures are aligned to the proper memory boundaries for efficient access.
What is padding in memory and why is it needed?
Order structure fields from largest to smallest data types to minimize padding, with doubles or longs first, followed by ints, shorts, and chars.
What is the rule of thumb for structure alignment?
fread()
What command is used to read from a binary file?
fwrite()
What command is used to write to a binary file?