Bifalgorithm post · Computer science one · Arrays of Structures
How can you combine contiguous structure storage with indirect access?
How can you combine contiguous structure storage with indirect access? (Computer science one · Arrays of Structures) — "It is also possible to take a “hybrid”…
Ideas in this flowchart
- A hybrid approach stores structures contiguously while allowing indirect access through a pointer array.
- The structures are stored together in contiguous memory.
- A pointer array provides indirect references to the stored structures.
- This approach is analogous to the contiguous two-dimensional integer array created earlier.
- The two-dimensional array used one call to malloc.
- Pointers were then set up for each row.
- The same storage strategy can be applied to structures.
- The process begins by declaring and allocating a dynamic array as before.
- The array size is set with n = 10.
- rosterData allocates space for 10 Student structures using malloc.