Stack overflow C++

前端 未结 8 2028
时光说笑
时光说笑 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:52

    In addition to the stack overrun, you have another problem -- one which is masked by your definitions of W and H.

    for(int i=0;i

    Your i loop should count from 0 to H-1, rather than W-1 (and the j loop should swap as well). Otherwise your code will only work correctly if W==H. If WH you will overrun your buffers.

    This same problem exists elsewhere in your code sample as well.

提交回复
热议问题