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

main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason

6 Answers   CSC,


Write a Program to accept different goods with the number, price and date of purchase and display them

0 Answers   HDFC,


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

0 Answers  


what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,






Write code for atoi(x) where x is hexadecimal string.

5 Answers   Adobe,


what is the difference between call by value and call by reference?

5 Answers   Genpact, Global Logic, Infosys,


how would a 4*3 array A[4][3] stored in Row Major Order?

0 Answers   HCL, Ignou,


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

0 Answers   Persistent,


What are # preprocessor operator in c?

0 Answers  


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

0 Answers  


Write a program to print a (*)pattern programming (A to Z) in capital in one programming ?

2 Answers   TCS,


Categories