General Discussions

malloc( ) in C

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:


int main()
    int * a;
    a = (int *) malloc(sizeof(int)*10);
    return 0;


One thought on “malloc( ) in C

Let me Know What you Think!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s