जॉइन Examsbook
1078 0

प्र: What is the difference between malloc() and calloc() functions?

  • उत्तर देखें
  • Workspace

उत्तर :
व्याख्या :

As against malloc(), calloc() needs two arguments, the number of elements  to be allocated and the size of each element. For example,  p = (int *) calloc (10, sizeof (int)); would allocate space for a 10- integer array. Additionally, calloc() would also set each of this element with a value 0. Thus the above call to calloc() is equivalent to: p = (int *) malloc (10 * sizeof (int)); memset (p, 0, 10 * sizeof( int ));

क्या आपको यकीन है

  त्रुटि की रिपोर्ट करें

कृपया संदेश दर्ज करें
त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई