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

create a C program that displays one z,two y's,three x's until twenty six A's. plzz answer i need it tomorrow.

4 Answers  


What are the types of i/o functions?

0 Answers  


what is const volatile?

2 Answers  


what is the difference between postfix and prefix unary increment operators?

3 Answers  


Write a program in C to convert date displayed in gregorian to julian date

0 Answers   HCL, Wipro,


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

0 Answers   Aspiring Minds,


What are dynamically linked and statically linked libraries?

2 Answers  


What is structure in c explain with example?

0 Answers  


How was c created?

0 Answers  


What should malloc(0) do?

0 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

2 Answers  


What should malloc() do?

0 Answers  


Categories