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...

we have to use realloc only after malloc or calloc ? or we
can use initially with out depending on whether we are
using malloc or calloc in our program ?

Answer Posted / vadivel t

Hi Vignesh,

Ur explanation about realloc() is correct. But the answer
is wrong. Because, it is possible to use realloc() before
using malloc() or calloc() function be used.

Lets, try the below code.

int *ptr;
ptr = (int *)realloc(NULL, 5);
printf("%d \n", ptr);

In this code, realloc will allocate five bytes of memory
and will return a valid pointer. It can be used in ur
program.

Conclusion:

It simple means that, if u pass a NULL pointer to a realloc
() function, it will exactly behave as like malloc().

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is uint8 in c?

1102


What is adt in c programming?

1154


Is c is a low level language?

1128


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

1222


Where static variables are stored in memory in c?

993


What does the function toupper() do?

1117


What is the difference between constant pointer and constant variable?

1217


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1524


Explain what is a program flowchart and explain how does it help in writing a program?

1093


What are different types of pointers?

1065


Why we use int main and void main?

1072


What is static volatile in c?

1019


What is the use of typedef in c?

1029


Why we use conio h in c?

1220


What are header files in c programming?

1127