C Programming
The Difference Between

What are the differences between malloc and calloc?

User Avatar
Wiki User
February 26, 2009 10:34AM

malloc returns a block of memory that is allocated for the

programmer to use, but is uninitialized. The memory is usually

initialized by hand if necessary -- either via the memset

function, or by one or more assignment statements that dereference

the pointer. An alternative is to use the calloc function,

which allocates memory and then initializes it. The malloc and

calloc differs in the number of arguments. The malloc allocates

memory of given size but the calloc can allocates array of memory

locations of given size.

Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.