关于自动退栈
当我调用 strlen(“Hello”)这字符串的时候 。进入strlen(const char *s)
{
return (*s ? strlen(s+1) +1 :0) ;
}
然后 由于*s != 0 开始递归 直到 *s = 0 终止循环; strlen(s+1)的返回值 等于 0 ;在然后 由于之前strlen("Hello")的调用还没得到返回值 系统就进行退栈,退栈过程中*s != 0,但也不会在调用strlen(s+1)函数 , 之前 strlen(s+1)的值 = 0 ,后面 还有个 +1 ,由于退栈中*s != 0, 就好比 strlen()这个函数返回值一直循环自增 1 ;直到
回到 s 地址首位,在把值返回到 最初调用地方
。我这样理解算不算正确,如果有误指点下 (退栈过程中应该调用该函数对么?)退栈时 地址 就在那个地方 所以不会调用该函数?
我这样理解算不算正确,如果有误指点下 (退栈过程中应该调用该函数对么?)