Stack overflow C++

前端 未结 8 2017
时光说笑
时光说笑 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条回答
  •  萌比男神i
    2020-12-02 00:49

    You are trying to allocate memory from stack. the maximum memory which can be allocated using stack is complier dependent. So try something like this to avoid this kind of exception.

    #include 
    #define W 1000
    #define H 1000 
    #define MAX 100000 
    void initImg(int img[], float dtr[]) 
    { 
    for(int i=0;i

    You can use new as well instead of using malloc to allocate memory from heap...

提交回复
热议问题