whats the difference between dynamic memory allocation and normal memory allocation?

malloc() is not supposed to zero the memory it returns. It seems that in your case it happens to be retrieving memory from the system that has not been previously used and is still zero. You certainly cannot count on this. calloc() on the other hand will zero memory for you before returning.

Leave a Comment