Stack overflow caused by recursive function

后端 未结 6 1309
面向向阳花
面向向阳花 2020-11-27 20:25

I\'m a beginner in C++. Yesterday I read about recursive functions, so I decided to write my own. Here\'s what I wrote:

int returnZero(int anyNumber) {
    if         


        
6条回答
  •  长情又很酷
    2020-11-27 20:53

    My guess is you stack is exactly big enough to fit 4792 entries - today. Tomorrow or the next, that number might be different. Recursive programming can be dangerous and this example illistrates why. We try not to let recursion get this deep or 'bad' things can happen.

提交回复
热议问题