I tried to create an error for try-catch testing with this code, where I expected to get an error while accessing an element a[3](fourth). Even if you don't get an error, the for loop should stop after five iterations, which never happens.
int a[3] = {1, 2, 3};
for(int i = 0; i < 5; i++)
{
std::cout << i << ": " << a[i] << std::endl;
}
exit:
0: 1
1: 2
2: 3
3: 1970756548
4: 4201552
5: 2686800
6: 2130567168
7: 0
8: 0
9: 2686824
10: 4198992
.
.
.
4150: 0
4151: 0
4152: 0
4153: 0
4154: 0
source
share