// This program unsafely accesses an area of memory by writing // values beyond an array's boundary. // WARNING: If you compile and run this program, it could crash. // Codeblocks IDE does not cause the program to crash, but it does overstep the array bounds and // and outputs garbage! #include using namespace std; int const MAX = 50; int main() { const int SIZE = 3; // Constant for the array size int values[SIZE]; // An array of 3 integers int count; // Loop counter variable // Attempt to store five numbers in the three-element array. cout << "I will try to store too many numbers in a 3 element array!\n"; for (count = 0; count < MAX; count++) values[count] = 100; // If the program is still running, display the numbers. cout << "If you see this message, it means the program\n"; cout << "has not crashed! Here are the numbers:\n"; for (count = 0; count < MAX; count++) cout << values[count] << endl; return 0; }