diff --git a/guide/english/c/malloc/index.md b/guide/english/c/malloc/index.md index 8f2683c0c8..8c6d9ea1e7 100644 --- a/guide/english/c/malloc/index.md +++ b/guide/english/c/malloc/index.md @@ -6,8 +6,15 @@ malloc() is a library function that allows C to allocate memory dynamically from malloc() is part of stdlib.h and to be able to use it you need to use `#include `. +## Synopsis + ``` + void *malloc(size_t size) + void *free(void *ptr); + ``` + ## Using Malloc malloc() allocates memory of a requested size and returns a pointer to the beginning of the allocated block. To hold this returned pointer, we must create a variable. + Here we'll make a pointer to a soon-to-be array of ints ```C int* arrayPtr; @@ -30,7 +37,6 @@ 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.