"stdlib.h" header file include in your program.
malloc stands for "memory allocation".
It allocate space in memory at run time according to given size.
It allocate space in single block.
Syntax
ptr = (cast-type*) malloc(byte-size);
NOTE: In above syntax ptr is a pointer type variable.
NOTE: If malloc() allocate space then it return pointer otherwise NULL.
It is used to release run time allocated memory. It means free() can frees occupied memory of malloc() or calloc().
Syntax
free(ptr);
calloc stands for "contiguous allocation".
calloc() allocates multiple block of memory.
Difference between malloc() and calloc():- malloc() allocates single block of memory but calloc() allocates multiple block of memory.
Syntax
ptr = (cast-type*)calloc(n, element-size);
If calloc() or malloc() allocated memory is not sufficient for requirement then we can change size of memory by realloc() at run time.
Here, ptr is reallocated with size of newsize.
Syntax
ptr =(cast-type*)realloc(ptr, newsize);
Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.
Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.
comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.
comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.
copyright © 2023