Example: x=(int*)malloc(100*sizeof(int));On successful execution of this statement a memory equivalent to 100 times the area of int bytes is reserved and the address of the first byte of memory allocated is assigned to the pointer x of type int
ptr is a pointer of type cast-type the malloc returns a pointer (of cast type) to an area of memory with size byte-size.ptr=(cast-type*)malloc(byte-size);
ptr=(cast-type*) calloc(n,elem-size);
The above statement allocates contiguous space for n blocks each size of elements size bytes. All bytes are initialized to zero and a pointer to the first byte of the allocated region is returned.
If there is not enough space a null pointer is returned.