I’m getting a segmentation fault in my C++ program when trying to access an array element. Here’s my code:
#include <iostream>
using namespace std;
int main() {
int arr[5];
cout << arr[10]; // Accessing out-of-bounds index
return 0;
}
How can I prevent this memory access issue?