Concept
How can you combine contiguous structure storage with indirect access?
ComputerScienceOne / Arrays of Structures
"It is also possible to take a “hybrid” approach to storing structures in arrays that stores them both contiguously, but also allows you to reference them indirectly through a pointer array. This is essentially what we did in Section 20.4.1 when we created a contiguous 2-dimensional array of integers. We made a single call to malloc and then had to setup the pointers to each “row.” To do this with structures, we can do something similar. First, we declare and allocate a dynamic array as before.\n\nint n = 10;\n\nStudent *rosterData = (Student *) malloc(n * sizeof(Student));"
Related Ideas
- How do you create and use an array of structures in C?ComputerScienceOne · Arrays of Structures
- What is 355 24?ComputerScienceOne · Passing Arrays of Structures . . . . . . . . . . . . . . . . . . . . .
- How do you pass an array of pointers to structures to a function?ComputerScienceOne · Passing Arrays of Structures
- What dynamic data structures does the C standard library provide?ComputerScienceOne · Dynamic Data Structures
- What are arrays used for?ComputerScienceOne · Arrays, Collections & Dynamic