C语言的函数有递归次数限制吗?

ShadowWonder 2013-05-26 11:51:41
如题,C语言的函数递归有次数限制吗?
...全文
600 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_20066565 2014-08-26
  • 打赏
  • 举报
回复
搞了一天,终于知道原因了。怪不得程序运行到一半就会跳出。
hugett 2013-05-27
  • 打赏
  • 举报
回复
只要栈不溢出就没问题。。C语言本身没有限制的
赵4老师 2013-05-27
  • 打赏
  • 举报
回复
除了时间和空间可能是没有限制的以外,其它任何具体事物都是有限制的。
赵4老师 2013-05-27
  • 打赏
  • 举报
回复
/STACK (Stack Allocations) Home | Overview | How Do I | Linker Options The Stack Allocations (/STACK:reserve[,commit]) option sets the size of the stack in bytes. To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click Output in the Category box. The Reserve text box (or in the reserve argument on the command line) specifies the total stack allocation in virtual memory. The default stack size is 1 MB. The linker rounds up the specified value to the nearest 4 bytes. The optional value specified in the Commit text box (or in the commit argument on the command line) is subject to interpretation by the operating system. In Windows NT, it specifies the amount of physical memory to allocate at a time. Committed virtual memory causes space to be reserved in the paging file. A higher commit value saves time when the application needs more stack space, but increases the memory requirements and possibly the startup time. Specify the reserve and commit values in decimal or C-language notation. Another way to set the size of the stack is with the STACKSIZE statement in a module-definition (.DEF) file. STACKSIZE overrides the Stack Allocations (/STACK) option if both are specified. You can change the stack after the .EXE file is built by using the EDITBIN tool.
starytx 2013-05-27
  • 打赏
  • 举报
回复
语言本身没有限制,内存资源是有限的,需要自己把握栈空间耗尽问题
begodliker 2013-05-27
  • 打赏
  • 举报
回复
只要栈不溢出就没有问题
winassembly 2013-05-27
  • 打赏
  • 举报
回复
C语言中,函数递归是依赖于栈实现的,所以函数的递归次数受栈空间的限制。但C语言本身并没有这个限制,所以要程序员自己操心这个问题,不要发生栈溢出,否则后果不可预知。
nadleeh 2013-05-27
  • 打赏
  • 举报
回复
引用 楼主 ShadowWonder 的回复:
如题,C语言的函数递归有次数限制吗?
木有,前提是别超出os限制和内存限制
bluewanderer 2013-05-26
  • 打赏
  • 举报
回复
一般实现每次函数调用都要占用一部分栈空间保存返回地址、局部变量和实参,栈空间用没了自然就没办法再继续递归了。
mujiok2003 2013-05-26
  • 打赏
  • 举报
回复
语言本身没有限制,但是小心栈溢出。

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧