disadvantages of realloc ?



disadvantages of realloc ?..

Answer / 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

More C Interview Questions

Are pointers really faster than arrays?

0 Answers  


main() { char p[] = "hello world!"; p = "vector"; printf("%s",p); }

2 Answers   Vector, Vector India,


wht is the difference between KPO and BPO ?

2 Answers   Accenture, BPO, HCK, HCL, Infosys,


What Is The Difference Between Null And Void Pointer?

0 Answers   TCS,


What are the 4 types of unions?

0 Answers  






What is the use of keyword VOLATILE in C?

1 Answers  


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


What is #include stdio h and #include conio h?

0 Answers  


How will you delete a node in DLL?

0 Answers   GrapeCity,


#include<stdio.h> #include<conio.h> void main() { int m=0111,n=20; printf("%d%d\n",m,n); getch(); }

1 Answers  


What is unary operator?

0 Answers  


Write a program that accept anumber in words

0 Answers  


Categories