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 exit(status) truly equivalent to returning the same status from main?

0 Answers  


Write a program to find whether the given number is prime or not?

6 Answers  


What is the output of the program given below #include<stdio.h> main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

21 Answers   ADITI, Student, TCS,


Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort

3 Answers  


increment operateor (++)and decrament(--) #include<stdio.h> #inclide<conio.h> main() { int x=15; while(x!=0) scanf("%d",&x); {

2 Answers   HCL, Syntel, TCS,






Give a fast way to multiply a number by 7

15 Answers   Accenture, Aricent, Microsoft,


What are the different types of objects used in c?

0 Answers  


Explain what is the difference between a free-standing and a hosted environment?

0 Answers  


What is hungarian notation? Is it worthwhile?

0 Answers  


Is it better to bitshift a value than to multiply by 2?

0 Answers  


what is the difference between <stdio.h> and "stdio.h"

14 Answers   Invendis, Kanbay, Mastek, MathWorks,


how write a addtion of two single dimensional array using of pointer in c language?

3 Answers   DRDO,


Categories