返回信息流#include <iostream>
int main()
{
void revers();
revers();
printf("\n");
return 0;
}
void revers()
{
int c=getchar();
if(c!='\n')
revers();
putchar(c);
}
主函数调用revers的时候,怎么一个带了void,一个又不带呢。高手给咱讲讲吧。
这是一条镜像帖。来源:北邮人论坛 / cpp / #29986同步于 2009/10/15
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
高手帮看看这个程序!
lichehuo
2009/10/15镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
【 在 lichehuo (忧郁门门主) 的大作中提到: 】
: 标 题: 高手帮看看这个程序!
: 发信站: 北邮人论坛 (Thu Oct 15 23:31:19 2009), 站内
:
: #include <iostream>
: int main()
: {
: void revers();
~~~~~~~~~~~~~~~~~~~~~~~~前向声明
: revers();
~~~~~~~~~~~~~~~~~~~~~~~~~调用
: printf("\n");
: return 0;
:
: }
: void revers()
~~~~~~~~~~~~~~~~~~~~~~定义
: {
: int c=getchar();
: if(c!='\n')
: revers();
: putchar(c);
: }
:
: 主函数调用revers的时候,怎么一个带了void,一个又不带呢。高手给咱讲讲吧。
: --
: 只有看看那美丽的晚霞,我才能坚持向西走下去-------悟空!
:
: ※ 来源:·北邮人论坛 http://forum.byr.edu.cn·[FROM: 2001:da8:215:9902:2097:3a6e:4452:*]
【 在 lichehuo 的大作中提到: 】
: 前向声明是什么意思?大哥给讲讲,谢谢了,小弟太菜。。
程序顺序执行下去,你的函数定义又在后面,所以别人不知道有这个函数。所以要前面声明一下。