calloc malloc and realloc code example
Example 1: allocate memory c
// Use malloc to allocate memory
ptr = (castType*) malloc(size);
int *exampl = (int*) malloc(sizeof(int));
// Use calloc to allocate and inizialize n contiguous blocks of memory
ptr = (castType*) calloc(n, size);
char *exampl = (char*) calloc(20, sizeof(char));
Example 2: difference between malloc and calloc and realloc
if (!(int *ptr = malloc(sizeof(int) * NUM_ELEM))){ // ERROR CONDITION HERE}