In the below program,
int *ar=new int();
int *ptr=(int *)realloc(ar,12);
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.