/* * Read some integers into an array, then echo them. */ #include using namespace std; // It's usual to give a name to array sizes. const int ARRMAX = 100; int main() { // We create native array and fill it with input values up to // the size of the array. If there are more input values, they // are ignored. int arr[ARRMAX]; int sub = 0; cout << "Enter some integers: " << endl; while(sub < ARRMAX && cin >> arr[sub]) { ++sub; } int num = sub; // Print them back out again. cout << "===============" << endl; for(int sub = 0; sub < num; ++sub) { cout << arr[sub] << " "; } cout << endl; }