The calloc ( ) Function
This function works exactly similar to malloc ( ) function except for the that it needs two arguments as against one argument required by malloc ( ) For example:
Int *ptr;
Ptr= (int*) calloc (10,2);
Here 2 specifies the size of data type in byte for which we want the allocation to be made which in this case 2 for integers. And 10 specify the number of elements for which allocation is to be made Remember that the argument passed to the function malloc was (n*10) it is a single argument (don't be confused) because multiple arguments are always separated by commas. The argument (n*10) has no commas in between hence it is a single argument though not a simple one but an expression Retiring to the above declaration after the execution of the above statement a memory block of 20 bytes is allocated to the requesting program allocated by mallloc () function contains garbage values while memory allocated by calloc () function contains all zeros the calloc () function is also available in the header file <stdlib.h> in TURBO C.
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 Calloc ( ) Function Assignment Help, The Calloc ( ) Function Homework Help, The Calloc ( ) Function Assignment Tutors, The Calloc ( ) Function Solutions, The Calloc ( ) Function Answers, Memory Allocations in C Assignment Tutors