Function malloc() is used to dynamically allocate the memory in C. The general syntax goes the following way:
(type_casting) malloc (size)
let us understand it in detail in the form of a conversation:


That’s how the components of the syntax:
“(type casting the pointer) malloc(specifying the size) “
can be understood.
A sample source code can be seen below:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int * a;
a = (int *) malloc(sizeof(int)*10);
return 0;
}
Reblogged this on PH Bytes.
LikeLike