Explain difference between calloc and malloc with an example. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Explain difference between calloc and malloc with an example.

15th Apr 2022, 5:07 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
1 Respuesta
+ 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