Stack overflow C++

前端 未结 8 2011
时光说笑
时光说笑 2020-12-02 00:06

This is my code. When I access dtr array in initImg function it gives a stack overflow exception. What might be the reason?

#define W 1000
#define H 1000
#de         


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 00:38

    You're creating giant arrays on the stack. Just use std::vector instead:

    std::vector image(W*H);
    std::vector dtr(W*H);
    

提交回复
热议问题