-
realloc()
{
int*ptr = (int*)malloc(10*sizeof(int));
ptr = realloc(ptr, 20*sizeof(int));
}
As realloc function is used to dynamically reallocate the memory and ptr is a pointer which points the dynamically allocated memory, but in case of realloc function why we have written (ptr, 20*sizeof(int))...
Why we have written ptr here?? Like a malloc function it should be some integer value.
-
Re: realloc()
Because malloc and realloc are two different functions and different functions very often have different parameters. ;)
http://msdn.microsoft.com/en-us/libr...(v=VS.71).aspx
http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx
-
Re: realloc()
How would it know which memory to reallocate if you don't tell it?
-
Re: realloc()
Do you have some kind of quiz in front of you Tanushreeagr?
http://forums.codeguru.com/showthread.php?t=523950