realloc() Function

In the below program,

int main()
{
int *ar=new int();
int *ptr=(int *)realloc(ar,12);
cout<<sizeof(ptr)<<" "<<sizeof(*ar);
}

I have reallocated the block size of ar pointer to 12. How can we assure that the memory of the pointed by ptr pointer is extended.

Please tell me if the memory is allocated via new(), can we still extend it using realloc() or it only works for malloc() and calloc() ?
You can't use malloc/new like that. They might not even use the same storage space.
new is not the same as malloc.
Topic archived. No new replies allowed.