0

The following simple c++ program always gives segmentation fault, which I cannot see the reason. This error goes away if I set N2=1000.

But I don't think the size of the lists is large at all. Commenting out evolve, I tried define 10 times larger arrays in the main function, which gives no error at all.

#include <iostream>

const int N1 = 481, N2 = 2000;

using std::cout; using std::endl;

void evolve(double* lista, double* listb){
    int ha = 10; ha++;
    cout << 88 << endl;
}

int main(int argc, char** argv){

    double list1[N1 * N2], list2[N1 * N2];
    evolve(list1, list2);
    cout << "End." << endl;
    return 0;
}
xiaohuamao
  • 160
  • 11

0 Answers0