Concept

How can structures be dynamically allocated?

ComputerScienceOne / Declaration & Initialization

"To solve this, we can instead use dynamically allocated structures. To dynamically allocate a structure, we use a pointer to a structure and a call to malloc() to allocate enough space for the structure. Even though our structure is user-defined, we can still use the sizeof() macro to determine the number of bytes required by the structure. The compiler and macro are “smart” enough to look at the structure declaration and determine the size of each of its variables and add up the total number of bytes required."

Related Ideas

How can structures be dynamically allocated? | ComputerScienceOne | Bifalgorithm | Bifalgorithm