This is wrong. It should be: int * arr = (int*)malloc(3 * sizeof(int));
A common mistake... which is one of the reasons why you shouldn't use malloc in C++.
Likewise, your reallocs have the same problem.
Consider using a vector instead.
the array have the size of 3, but the 4 position, remain in memory
exist something to delete the 4 position?
After you realloc to reduce the buffer, the [3] position no longer exists (for your purposes). Whether or not it gets wiped/cleaned does not matter. For all you care, it is no longer accessible.
After you realloc to reduce the buffer, the [3] position no longer exists (for your purposes). Whether or not it gets wiped/cleaned does not matter. For all you care, it is no longer accessible.