while
data_ptr
is (presumably) a pointer to a (single) int, that int is actually the first element in an array. You need to allocate the entire array with data_ptr = new int[v.capacity];
and then memcpy the first n_elements
elements over.