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

differentiate between const char *a; char *const a; and char const *a;

2 Answers   College School Exams Tests, HCL, TCS,


What is a MAC Address?

0 Answers  


what is the output on the screen? int n; n=printf("my name is %d",printf("kiran %d",printf("kumar"))); printf("\n %d \n",n);

4 Answers   TCS,


Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

0 Answers  


Explain what are multibyte characters?

0 Answers  






Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

0 Answers  


5) Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.without using big int and exponential function

1 Answers   TCS,


program to find a smallest number in an array

15 Answers   Microsoft, Sony,


who is the editor of 'pokemon'?

1 Answers  


Explain what are compound statements?

0 Answers  


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

0 Answers  


Is main is user defined function?

0 Answers  


Categories