开发者

dynamics structure

I declare this structure:

struct matrix27 {
  double mat27[1083][1083];
} a1;

My program runs with this structure.

开发者_开发技巧 But when I declare this structure:

struct matrix27 {
  double mat27[5034][5034];
} a1;

My program won't run (it compiles, but when I run it, windows stop it."filename.exe has stopped working").

I used a1 in several functions, I want to declare it dynamically, how can i do that?


I suppose 5034^2*sizeof(double) is too big a chunk of memory to fit into your platform's stack space. (It's almost 200MB on my platform and a program trying to allocate so much stack space crashes.) You can circumvent it by putting the memory on the heap.

And make sure you read the C++ array FAQ.


sbi is right. If you really want to put this structure on the stack, you'll have to increase your stack size. If you're using Visual Studio, it can be done choosing (project) Properties -> Configuration Properties -> Linker -> System -> Stack Reserve Size.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜