disadvantages of realloc ?

Answer Posted / babitha

Library:<stdlib.h>
define:void *realloc(void *ptr, size_t size);
it modifies the existing size of block to new size with
copies of existing data.simply it add/delete the memory of
existed pointer based on new size without changing its
contents and it returns the pointer of first location.
possible cases:
1.if size >0,ptr is not null->modify the ptr with new size
and return pointer of 1st location.
2.if size is 0,ptr is not null->it would not change the
size of pointer but delete the existing contents.
3.if size >0,ptr is null->create new ptr with that size and
return that new pointer.
4.if there is not enough space to rellocate ptr,then it
return null pointer with out changing the block of data.
case 2 and 4 are disadvantages,since orignial contents are
getting deleted and also if we trying to use null pointer
then it would crash the program.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of errors?

648


What are types of structure?

610


What are the advantage of c language?

556


What is extern c used for?

573


List some basic data types in c?

563






How will you print TATA alone from TATA POWER using string copy and concate commands in C?

922


Can we change the value of constant variable in c?

580


What is typeof in c?

611


Explain the use of #pragma exit?

703


Explain main function in c?

632


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

764


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1749


Why double pointer is used in c?

573


What are the features of c language?

625


‎How to define structures? · ‎

636