Thursday 18 May 2017

Dynamic memory allocation in C Tccicomputercoaching.com



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.
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

No comments:

Post a Comment