Limit recursive calls in C++ (about 5000)?

前端 未结 3 677
独厮守ぢ
独厮守ぢ 2021-01-05 23:03

In order to know the limit of the recursive calls in C++ i tried this function !

void recurse ( int count ) // Each call gets its own count
{
printf(\"%d\\n\         


        
3条回答
  •  半阙折子戏
    2021-01-06 00:01

    You've probably run out of stack space.

    Every time you call the recursive function, it needs to push a return address on the stack so it knows where to return to after the function call.

    It crashes at 4716 because it just happens to run out of stack space after about 4716 iterations.

提交回复
热议问题