// Allocates new memory
int* temp = newint[size];
// Copies values over to temp
for (int* i = arra; i; i ++)
*temp = *i;
// Frees old memory
// Points arra to the resized array
arra = temp;
I'm tired, I'm still not great with pointers, and I haven't tested it, but in theory, that should work. I don't know of an easier way to do it while still using arrays.
Note: There are no new values, aside from the ones in the random memory when allocating the memory for the array (meaning you might have some garbage values in the array until you assign those values something.
If you're looking for something a little more dynamic, please consider using vectors, they're much easier to think about and to use.
You need to specify what's not going right. When I see it doesn't run properly, I assume it doesn't run at all. If you're getting errors, you need to share them, if you're getting some odd results, you need to share them. It also helps if I know what kind of output you're expecting, and what your output is.
If you use your function the way you are now, you're going to end up trying to write to memory that you're not allowed to and crashing your program. I simply showed you a way to fix that. However, you need to implement that properly into your code before I can help you resolve any other issues, since writing to unallocated memory can cause a lot of issues.