Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Difference between realloc() and free?

Answers were Sorted based on User's Feedback



Difference between realloc() and free?..

Answer / eswaramoorthy

realloc() is use to reset already allocated memory size.
free() is use to destroy already allocated memory size.

Is This Answer Correct ?    26 Yes 3 No

Difference between realloc() and free?..

Answer / alka

free()is a macro used to deallocate memory.
when we need more memory realoc() reallocate memory
according to given size, if there is no memory 4
alocation ,it will free previous allocated memory &
allocate new one using malloc().
ex: int *p = realloc(p,sizeof(p)*2);

Is This Answer Correct ?    15 Yes 6 No

Difference between realloc() and free?..

Answer / keerthana

realloc() is used to reallocate the memory when the memory
which is already allocate is not sufficient
free() is used to free the memory space

Is This Answer Correct ?    5 Yes 1 No

Difference between realloc() and free?..

Answer / jayasrinivas.donavalli

realloc() can be use to reallocation of the memory if the
memory already created is insufficient,
but free can be used to destroy the memory which was
already created

Is This Answer Correct ?    7 Yes 5 No

Difference between realloc() and free?..

Answer / gouthami..

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 ?    1 Yes 0 No

Difference between realloc() and free?..

Answer / fathimath fahima j

free :
#include <cstdlib>
Void free (void *ptr);

Free() function returns the memory
Pointed to by ptr to the heap. 

Realloc :
#include<cstdlib>
Void *realloc(void *ptr,size_t size);

The realloc function changes the size of
the previously allocated memory pointed to by ptr to dat specified by size.

Is This Answer Correct ?    1 Yes 0 No

Difference between realloc() and free?..

Answer / pratik bokade

✨Free() method is used to dynamically de-allocate the memory.
Syntax: Free(Ptr);
✨Realloc() or reallocation method is used dynamically changed the memory allocation of a previously allocated memory.
Syntax : Ptr=Realloc(Ptr, new size);

Is This Answer Correct ?    0 Yes 0 No

Difference between realloc() and free?..

Answer / khadeer.k

realloc():
memory when gets decreased, we can allocate it with the
function called realloc().
free:
it is used to free the memory in the program.

Is This Answer Correct ?    7 Yes 8 No

Difference between realloc() and free?..

Answer / praviss

An existing block of memory which was allocated by malloc() subroutine, will be freed by free() subroutine. In case , an invalid pointer parameter is passed, unexpected results will occur. If the parameter is a null pointer, then no action will occur.
Where as the realloc() subroutine allows the developer to change the block size of the memory which was pointed to by the pointer parameter, to a specified bytes size through size parameter and a new pointer to the block is returned. The pointer parameter specified must have been created by using malloc(),calloc() or realloc() sub routines and should not deallocated with realloc() or free() subroutines. If the pointer parameter is a null pointer, then no action will occur.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More OOPS Interview Questions

what is oppes

2 Answers  


Whats is abstraction in oops?

0 Answers  


can we create and enter the data & hide files using programmes ?

2 Answers   Wipro,


Why we are use # in begning of programme of c++.

2 Answers   Syntel,


What is extreme programming?

2 Answers  


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

0 Answers  


how to tackle technical questions

1 Answers  


Conversion from a basic type to a class type may be achieved using______________

5 Answers   HCL,


ambiguity regulation of multiple inheritance with example.

1 Answers  


all about pointers

2 Answers  


143.what is oops principles?

10 Answers  


write knight tour problem which is present in datastructure

0 Answers  


Categories