H Lecture Notes - Lecture 8: C Dynamic Memory Allocation

7 views2 pages

Document Summary

In some situations, data is dynamic in nature. Number of data item keeps changing during program execution. Dynamic memory allocation: ability of a program to use more memory space at execution time. Memory space required can be specified at the time of execution. C supports allocating and freeing memory dynamically using library routines. The library has functions responsible for dynamic memory management. Allocates the memory of requested size and returns the pointer to the first byte of allocated space. The pointer returned is usually of type void. It means that we can assign malloc function to any pointer. Syntax : ptr = (type *) malloc (byte_size); This function is used to allocate multiple blocks of memory. It is a dynamic memory allocation function which is used to allocate the memory to complex data structures such as arrays and structures. syntax : ptr = (type *) calloc (n, byte_size); It is used to modify the size of previously.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents