Explain difference between calloc and malloc with an example. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Explain difference between calloc and malloc with an example.

15th Apr 2022, 5:07 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
1 ответ
+ 3
calloc allocates memory and initializes it to zeros whereas malloc does not initialize the memory which still contains whatever values were there...source of unpredictable behavior if you don't address this in your code.
15th Apr 2022, 6:36 AM
Paul K Sadler
Paul K Sadler - avatar