CSO101: Computer Programming
Structures 1
O.S.L. Bhavana
Composite Data Types
of 158 students?
Maintaining many arrays and keeping track of their indices is combursome
Structures
Structures : Definition
Structures : Declaration of variables
Structures: Memory Map
Structure: Accessing Fields of a struct
Structures: Initialization (with list)
Structures: Initialization after declaration
Arrays of Structures
Array of Structures
Memory Map of Array of Structures
Assignment of Structures
Structures: Nesting
Structures: sizeof
in the order they are declared in the structure
Structures: sizeof
Structures: Data Alignment
0 | 1 | 2 | 3 |
4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
A word
Another word
Structures: Data Alignment
0 | 1 | 2 | 3 |
4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
Memory cells 6,7,8,9
do not form a word
Structures: Data alignment
Structures: Data Alignment
8 bytes is the size of the above struct.
First byte for char;
2nd byte left for alignment;
3,4 for short int
5-8 for int