Check out example codes for "how to use malloc in c". It will help you in understanding the concepts better.

Code Example 1

ptr = (castType*) malloc(size);

Code Example 2

int* a =(int*)malloc(sizeof(int))

Code Example 3

ptr = (cast-type*)calloc(n, element-size);

Code Example 4

ptr = (cast-type*) malloc(byte-size)

Learn ReactJs, React Native from akashmittal.com