The Malloc ( ) Function
The malloc function allocates a block of memory in bytes. The user should explicitly give the block size it requires for the use. The malloc function is like a request to the RAM of the system to allocate memory if the request is granted (i.e.. the malloc function stays successful in allocating memory) returns a pointer to the first block of that memory. The type of the pointer it returns is void which means that we can assign it any type of pointer. However if the malloc( ) function fails to allocate the required amount of memory it returns a NULL The malloc ( ) function is available in header file alloc h in TURBO C and on UNIX it will be available in header file <malloc.h> The syntax of this function is an follows :
Malloc (number of elements*size of each element):
For example,
Int *ptr ;
Ptr=malloc (10*sizeof(int))
Data Structure & Algorithms Assignment Help, Live Experts
Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.
ExpertsMind.com - The Malloc ( ) Function Assignment Help, The Malloc ( ) Function Homework Help, The Malloc ( ) Function Assignment Tutors, The Malloc ( ) Function Solutions, The Malloc ( ) Function Answers, Memory Allocations in C Assignment Tutors