My program was showing strange behavior, until I discovered that there was an overflow of array , for example:
int arr[3];
for (int i = 0; i<10; i++) {
arr[i]=i;
cout << arr[i];
}
In this light example, i
exceeds the limit of only 3 elements in array .
However, C ++ does not say anything and the program literally detonates memory, generating unpredictable behavior in the program.
How can I make C ++ warn (and avoid) when this happens?