English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i only know 1, the calloc() has initialization, while malloc() has none

2007-01-31 21:03:59 · 3 answers · asked by Sammy Baby 1 in Computers & Internet Programming & Design

3 answers

Hope this link will help you ...
http://www.faqfarm.com/Q/What_is_the_difference_between_malloc_and_calloc_functions

2007-01-31 21:16:56 · answer #1 · answered by @rrsu 4 · 0 0

calloc() allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. The memory is set to zero.

malloc() allocates size bytes and returns a pointer to the allocated
memory. The memory is not cleared.

2007-02-01 05:08:41 · answer #2 · answered by Baskar Mookkan 2 · 0 0

Hello
malloc() used to allocate one block of memory.
calloc() used to allocate multiple blocks of memory.
realloc () used to allocate more memory if allocated memory
is not sufficient.
free() is used to release the allocated memory.
all are in alloc.h (allocation)
Eg;
int *ptr = (int*) malloc(20); //allocates 20 bytes as single block
Hope u know calloc.

Thanks
Jana.KV

2007-02-01 05:09:30 · answer #3 · answered by djanartanan 2 · 0 0

fedest.com, questions and answers