I have written a small program but couldn't understand why it does't crash when a is accessed out of bounds?
#include <iostream>
using namespace std;
int main()
{
double *a = new double[4];
a[0]=1;
a[1]=2;
a[2]=3;
a[3]=4;
cout <<"size of double:"<<sizeof(double)<<endl;
a[100]=100; // why is it not crashing here?
return 0;
}
Could someone explain me whats happening here? Shouldn't this crash at a[100]=100?