Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

In c malloc allocate contiguos or non contiguos memory allocation ?

And how we use that memory?

user-image
Question added by mayur agarwal
Date Posted: 2013/09/30
Muhammed Ajmal Seeraveetil
by Muhammed Ajmal Seeraveetil , Software Engineer , Wipro

 

      void *ptr= malloc (20);

      int *iptr= (int *)ptr; //4 byte access  

      char *cptr=(char *)ptr; // Single byte access 

  • Malloc allocates contigous block of memory  
  • Memory is alocated from heap 
  • Memory can be used by typcasting the void pointer returned by the malloc 

malloc/calloc both functions allocate memory in one contigous block

KASHIF ZEESHAN
by KASHIF ZEESHAN , Corporate Trainer , ORION EDUTECH PVT LTD

Non Contagious

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.