From 46ae11f95832d1d0743be609f9a69890fbb073a8 Mon Sep 17 00:00:00 2001 From: Jay Patel Date: Tue, 2 Apr 2019 00:00:39 +0530 Subject: [PATCH] mallo() vs calloc() (#30669) --- guide/english/c/malloc/index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/guide/english/c/malloc/index.md b/guide/english/c/malloc/index.md index 44932c9b60e..8f2683c0c85 100644 --- a/guide/english/c/malloc/index.md +++ b/guide/english/c/malloc/index.md @@ -30,3 +30,8 @@ This statement will deallocate the memory previously allocated. C does not come * Allocating memory allows objects to exist beyond the scope of the current block. * C passes by value instead of reference. Using malloc to assign memory, and then pass the pointer to another function, is more efficient than having the function recreate the structure. + +Difference between malloc() and calloc() +1. Malloc() does not assignes the created memory to zero where as calloc() assignes the memory created to zero. +2. malloc() is best suitable for Character data and calloc() for Numeric data. +3. Malloc() can give garbage value if it deals in numeric data as it does not assignes the meory to zero.