Arrays are subscripted from zero up to the size less one.
Unlike Java, the size must be a constant value. Also, no new
is required.
/*
* Read some integers into an array, then echo them.
*/
#include <iostream>
#include <array>
int main()
{
// Read them in.
std::array<int, 10> arr;
int sub = 0;
std::cout << "Enter some integers: " << std::endl;
while(std::cin >> arr[sub]) {
++sub;
}
int num = sub;
// Print them back out again.
std::cout << "===============" << std::endl;
for(int sub = 0; sub != num; ++sub) {
std::cout << arr[sub] << " ";
}
std::cout << std::endl;
}
[more info]