返回信息流#include <stdio.h>
void reverse( const char * const sPtr ); /* prototype */
int main()
{
char sentence[ 80 ]; /* create char array */
printf( "Enter a line of text:\n" );
/* use gets to read line of text */
gets( sentence );
printf( "\nThe line printed backwards is:\n" );
reverse( sentence );
return 0; /* indicates successful termination */
} /* end main */
/* recursively outputs characters in string in reverse order */
void reverse( const char * const sPtr )
{
/* if end of the string */
if ( sPtr[ 0 ] == '\0' ) { /* base case */
return;
} /* end if */
else { /* if not end of the string */
reverse( &sPtr[ 1 ] ); /* recursion step */
putchar( sPtr[ 0 ] ); /* use putchar to display character */
} /* end else */
} /* end function reverse */
这个程序的reverse 函数我根本看不懂,哪位大牛给我解释一下?
这是一条镜像帖。来源:北邮人论坛 / cpp / #18646同步于 2009/1/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
[求助]递归函数
rayzl0523
2009/1/13镜像同步4 回复
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复