malloc() vs calloc() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

malloc() vs calloc()

What is the deference between the both They are do the same think theoretically (allocates contiguous bloces of memory) malloc takes the size in byte Calloc takes a number of items and the size of type When I can NOT use malloc and when I can't use calloc

13th Mar 2019, 5:39 PM
ABADA S - avatar
5 Answers
+ 3
yes ‎‏‪ABADA S‬‏‎ , malloc nd calloc do same thing that is used to allocate memory dynamically for c language... difference of argument in malloc and calloc is already described by you.. main difference is that malloc just allocates memory block nd returns to us where as calloc first allocates memory block and then initialise it with zero.... so, calloc takes a bit more time as it initialise also compared to malloc.
13th Mar 2019, 8:27 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 5
Good job Thanks for helping
13th Mar 2019, 9:06 PM
ABADA S - avatar
+ 3
Thanks master Ketan Lalcheta I got it Java guy I did not find my other post I tried to use google but I field
13th Mar 2019, 8:32 PM
ABADA S - avatar
+ 1
You posted this question twice please delete this one, i am a Java guy tho hope someone help you, or else you can use google☺
13th Mar 2019, 5:44 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar