What is the use of malloc and calloc functions
Hi Guys,
I am beginner in the field of programming. I just completed my basic 'C' language. But the concept of the "malloc" and "calloc" functions is still unclear. Even I don't have any idea regarding what is the basic use of the "malloc" and "calloc" functions.
Can you able to help me to clear my doubts regarding "malloc" and "calloc" functions?...
Re: What is the use of malloc and calloc functions
"malloc" is a subway for performing allocation of the dynamic memory in the C++ and C languages."malloc" is a important part of the standard library of c & c++ languages. More than one implementations of "malloc" is valid, In which each of them performs entirely different depending on the code of the programming.
Programs should be properly manage dynamic memory which is allocated by the "malloc" function for avoiding any memory corruption and memory leaks.
Re: What is the use of malloc and calloc functions
Hi,
The malloc and calloc functions are basically the memory allocation functions.
In an application which developed by using the big memory model, the "calloc" & "malloc" functions appear to lose very large memory blocks when the allocation's segment value changes.
For e.g, if an application requests two 32K blocks of memory & the value of segment of the 2nd pointer is entirely different from the value of the segment of 1st pointer,then the variation between the pointers is approx 48,000 bytes.
The "malloc" function is useful to allocate a large memory block from "ms-dos" & continue to allocates memory until it is full
Re: What is the use of malloc and calloc functions
For your kind information calloc and malloc are the function whch are used in the process of the memory allocation.
But there are some difference between them which are as follows:
1. For calloc we have to pass 2 arguments ,while for malloc it is single.
2.calloc function is useful to allocates block of memory while malloc used to allocate byte of memory.
3.calloc initializes the memory allocated to '0', while malloc does not.