Dynamic memory allocation in C Tccicomputercoaching.com

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

c-language-course-in-ahmedabad

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.

malloc()

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()

free(ptr);

C realloc()

ptr = realloc(ptr, newsize);

To learn more in detail call us 9825618292

Mail to tccicoaching@gmail.com

Visit us @ https://tccicomputercoaching.wordpress.com/

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

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s