摘要: int func(char *str){assert(str != NULL);while(*str != '\0'){//return (func(str+1))+1;return (func(str++))+1; //为什么不行?//return (func(++str))+1;}}void main(){char* str = "Hello,World";int k = func(str);cout<<k<<endl; 阅读全文
posted @ 2012-11-17 22:15 CBDoctor 阅读(263) 评论(0) 推荐(0)
摘要: http://www.cnblogs.com/zlja/archive/2010/06/30/2449147.html下面是个关于递归调用简单但是很能说明问题的例子:/*递归例子*/#include<stdio.h>void up_and_down(int);int main(void){ up_and_down(1); return 0;}void up_and_down(int n){ printf("Level %d:n location %p/n",n,&n); /* 1 */ if(n<4) up_and_down(n+1); print 阅读全文
posted @ 2012-11-17 21:58 CBDoctor 阅读(512) 评论(0) 推荐(0)