|
-
May 21st, 2012, 10:17 AM
#1
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.
TANUSHREE-AGRAWAL...
-
May 21st, 2012, 10:22 AM
#2
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
-
May 21st, 2012, 10:24 AM
#3
Re: realloc()
How would it know which memory to reallocate if you don't tell it?
-
May 21st, 2012, 10:36 AM
#4
Re: realloc()
Do you have some kind of quiz in front of you Tanushreeagr?
http://forums.codeguru.com/showthread.php?t=523950
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|