Chapter 19Linked Lists

DOI: 10.1201/9781003257981-19

This chapter explains how to create a data structure whose size can grow and shrink as needed.

19.1 Dynamic Data Structure

The previous chapters described two common ways to allocate memory: The first scenario is static allocation on the stack memory when the sizes are known. If only stack memory is used, memory leak is not possible and this is an advantage. This is an example using stack memory for an array of 100 integers:

In many cases, however, the size of the needed memory is unknown when the program is written. Instead, the size is known after the program starts running. This is the second scenario. An example is shown below, ...

Get Intermediate C Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.