Added malloc() review (#33307)
This commit is contained in:
committed by
Christopher McCormack
parent
f590fecb34
commit
97284992ec
@ -68,6 +68,7 @@ int main()
|
||||
* Malloc is used for dynamic memory allocation and is useful when you don't know the amount of memory needed during compile time.
|
||||
* 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.
|
||||
* ```malloc()``` reserves a block of memory of specified size and return a pointer of type void which can be casted into pointer of any form.
|
||||
|
||||
Difference between malloc() and calloc()
|
||||
1. Malloc() does not assignes the created memory to zero where as calloc() assignes the memory created to zero.
|
||||
|
Reference in New Issue
Block a user