This is the same question asked in C# but i need for C++
How can I copy a part of an array to another array?
Consider I\'m having
int[] a = {
Assuming you want a dynamically-allocated array as in the C# example, the simplest way is:
std::vector b(a.begin() + 1, a.begin() + 4);
This also has the advantage that it will automatically release the allocated memory when it's destroyed; if you use new yourself, then you'll also need to use delete to avoid memory leaks.