Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Programming General (http://siteownersforums.com/forumdisplay.php?f=44)
-   -   C language (http://siteownersforums.com/showthread.php?t=204445)

thevyakar 11-08-2017 02:13 AM

C language
 
What is the difference between malloc() and calloc()?

Lebar.123 11-08-2017 04:57 AM

Basically there is no difference between the two besides calloc() zero-initializes the buffer, while malloc() leaves the memory uninitialized.

nele 11-14-2017 06:47 AM

hi, thevyakar

There are two major differences between malloc and calloc in C programming language: first, in the number of arguments.

The malloc() takes a single argument, while calloc() takess two. Second, malloc() does not initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.

thevyakar 11-17-2017 03:02 AM

Thank you all for your answers :)


All times are GMT -7. The time now is 02:07 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.