Dynamic Memory allocation is the process of allocating memory to program in runtime.
The various dynmaic memory allocation functions available in C are
Here n refers to the number of blocks
The various dynmaic memory allocation functions available in C are
- Malloc:Allocates specified number of bytes un memory and returns the pointer to the first byte allocated.
pointer=(cast-type*)malloc(size in bytes)
- Calloc:Creates more than one block of memory and returns the pointer to the first byte in the first block.
Here n refers to the number of blocks
- realloc:Used to reallocate a previous allocated memory area.
pointer=realloc(new pointer,newsize);
- free:Used to clear previously allocated memory so that memory is used efficiently.
free(pointer name);
No comments:
Post a Comment