I write a simple code in C++ and I compile it with g++ on linux ubuntu 11.04 and I don’t get any errors but when I run the executable file, I get this error “segmentation fault”.
I know that my code has no problem and tHat this error is related to the compiler.
Can somebody help me?
My code is :
#include <math.h>
int main()
{
double a[200][200][200],b[200][200][200],c[200][200][200];
int i,j,k;
double const pi=3.14;
for(k=0;k<200;k++)
{
for(j=0;j<200;j++)
{
for(i=0;i<200;i++)
{
a[i][j][k]=sin(1.5*pi*i)*cos(3.5*pi*j)*k;
b[i][j][k]=cos(1.5*pi*i)*cos(2.5*pi*k)*j;
c[i][j][k]=a[i][j][k]-b[i][j][k];
}
}
}
}
This function can help you: