Dynamic memory allocation in C

Dynamic memory allocation allows your program to obtain more memory space while running, or to release it if it’s not required.


In simple terms, Dynamic memory allocation allows you to manually handle memory space for your program.

Although, C language inherently does not have any technique to allocate memory dynamically, there are 4 library functions under “stdlib.h” for dynamic memory allocation.


The name malloc stands for “memory allocation”.

ptr = (cast-type*) malloc(byte-size)

C calloc()

The name calloc stands for “contiguous allocation”.

ptr = (cast-type*)calloc(n, element-size);

C free()

You must explicitly use free() to release the space.

syntax of free()


C realloc()

ptr = realloc(ptr, newsize);

To learn more in detail call us 9825618292

Mail to

Visit us @

For more information about Computer course, Computer class, C language course in Ahmedabad, TCCI



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s