What is the difference between realloc() and free()



What is the difference between realloc() and free()..

Answer / nitin

The free subroutine frees a block of memory previously
allocated by the malloc subroutine. Undefined results occur if
the Pointer parameter is not a valid pointer. If the Pointer
parameter is a null value, no action will occur. The realloc
subroutine changes the size of the block of memory pointed to
by the Pointer parameter to the number of bytes specified by
the Size parameter and returns a new pointer to the block. The
pointer specified by the Pointer parameter must have been
created with the malloc, calloc, or realloc subroutines and
not been deallocated with the free or realloc subroutines.
Undefined results occur if the Pointer parameter is not a
valid pointer.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Interview Questions

Is swift based on c?

0 Answers  


Meaning of () in c

1 Answers  


Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986

1 Answers  


What are types of functions?

0 Answers  


#include<stdio.h> main() {int i=1;j=1; for(;;) {if(i>5) break; else j+=1; printf("\n%d",j) i+=j; } }

7 Answers   HCL,






When should I declare a function?

0 Answers  


Explain can static variables be declared in a header file?

0 Answers  


what type of errors are checked during compilation

3 Answers  


main() {int a=200*200/100; printf("%d",a); }

14 Answers   TCS,


write a c prog for removing duplicate character from an array and sorting remaining elements using a single array

1 Answers  


Which is better between malloc and calloc?

0 Answers  


WAP TO ACCEPT STRING AND COUNT A COMES N TIMES B COMES N TIMES C COMES N TIMES D COMES N TIMES AND SO ON......... AT LAST UNTIL Z COMES N TIMES...............

3 Answers  


Categories