what are the various memory handling mechanisms in C ?

Answer Posted / priya

The malloc function allows the programmer to create a block of memory of a given size:

malloc ( long integer lBlockSize ) returns void *

If we decide, during the execution of the program, that we might need to expand, or contract this memory block, we can use the realloc function:

realloc ( void * pBlock, long int lNewBlockSize ) returns void *

When the memory block is no longer used, then it must be returned back to the operating system, by calling the free function:

free ( void * pBlock )

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you understand by normalization of pointers?

842


What is a pointer variable in c language?

864


How can you find the day of the week given the date?

870


What are called c variables?

794


What is struct node in c?

832


How is a null pointer different from a dangling pointer?

805


Write a program to swap two numbers without using the third variable?

832


What is LINKED LIST? How can you access the last element in a linked list?

851


Write a program which returns the first non repetitive character in the string?

852


Why is c platform dependent?

822


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

839


What does node * mean?

979


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

892


Which one would you prefer - a macro or a function?

864


What is main return c?

756