#include <iostream>
void print_array(std::ostream& os, int* arr, std::size_t sz)
{
os << '{';
for (std::size_t i = 0; i < sz; ++i) {
os << arr[i];
if (i != sz-1) os << ", ";
}
os << '}';
}
int main()
{
const std::size_t amount = 10;
int *numbers = newint[amount];
for (std::size_t i = 0; i < amount; ++i)
numbers[i] = 100 + i;
print_array(std::cout, numbers, amount);
delete[] numbers;
}
I highly recommend not using naked new/delete and using std::array instead of C-Style arrays.
I made the print_int_array(aka print_array()) function take a variable size, so it isn't completely useless.