This code, which allocates in the area variable the amount of 1s there is in a zeroed array (yes, it only does this), compiles in ideone.com and does not give Runtime Error:
#include <iostream>
#define MAX 1500
using namespace std;
int main()
{
int i, j, plano[MAX][MAX]={}, area=0;
for(i=0; i<MAX; i++){
for(j=0; j<MAX; j++){
if(plano[i][j]==1) area+=1;
}
}
return 0;
}
But this one, whose only difference is that it displays the area variable by cout, gives Runtime Error because of segmentation failure, when the C ++ version is 4.3.2: link
#include <iostream>
#define MAX 1500
using namespace std;
int main()
{
int i, j, plano[MAX][MAX]={}, area=0;
for(i=0; i<MAX; i++){
for(j=0; j<MAX; j++){
if(plano[i][j]==1) area+=1;
}
}
cout<<area;
return 0;
}
When testing with C ++ 14, it works ... Why does this occur?