| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 848 人关注过本帖
标题:出现这个报错是什么意思?
只看楼主 加入收藏
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
结帖率:42.86%
收藏
 问题点数:0 回复次数:7 
出现这个报错是什么意思?
程序代码:
# include<stdlib.h>
# include<stdio.h>
# define MAXSIZE 20
typedef int elemtype;
typedef struct
{
elemtype stack[MAXSIZE];
int top;
}SeqStack;



InitStack(SeqStack *s)
{
s->top=0;
}
PushStack(SeqStack *s,int n)
{
int a,i;
if(s->top>=MAXSIZE)
{
printf("overflow");
return -1;
}
printf("输入%d个元素:",n);
for(i=0;i<n;i++)
{
if(s->top>=MAXSIZE)
{
printf("overflow\n");
return -1;
}
scanf("%d",&a);
s->stack[s->top]=a;
s->top++;
}
return 1;
}
POPStack(SeqStack *s)
{
if(s->top<=0)
{
printf("栈空");
return -1;
}
while(s->top>0)
{
s->top--;
printf("%d ",s->stack[s->top]);
}
return 1;
}
main()
{
int i,n;
SeqStack s;
InitStack(&s); //初始化一个大小为20的栈s
printf("输入要入栈的元素个数:");
scanf("%d",&n);
PushStack(&s,n);
printf("出栈后的元素排序:");
POPStack(&s); //将栈s中的元素依次退栈,再依次存放到栈t中
printf("\n");
}








[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:14: error: ISO C++ forbids declaration of `InitStack' with no type
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:18: error: ISO C++ forbids declaration of `PushStack' with no type
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:40: error: ISO C++ forbids declaration of `POPStack' with no type

能帮忙改对吗?
2014-10-15 21:54
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
收藏
得分:0 
有人吗
2014-10-15 22:22
ditg
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:16
帖 子:852
专家分:1937
注 册:2014-4-10
收藏
得分:0 
返回值类型?

梦想拥有一台龙芯3A-4000
2014-10-15 23:42
roulcoo
Rank: 1
等 级:新手上路
帖 子:3
专家分:5
注 册:2014-7-18
收藏
得分:0 
函数没有定义返回值类型
2014-10-16 09:48
whb123
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-10-16
收藏
得分:0 
新手看不懂。。。
2014-10-16 10:59
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
收藏
得分:0 
有人吗
2014-10-17 12:06
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:14: error: ISO C++ forbids declaration of `InitStack' with no type
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:18: error: ISO C++ forbids declaration of `PushStack' with no type
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名8.cpp:40: error: ISO C++ forbids declaration of `POPStack' with no type

编译器已经告诉你答案了:ISO C++ 不允许无返回类型的函数定义。
第几行、什么原因,都说得很清楚,为什么不愿意翻一翻词典查看?难道别人的解答比编译器更权威吗?


[ 本帖最后由 TonyDeng 于 2014-10-17 12:13 编辑 ]

授人以渔,不授人以鱼。
2014-10-17 12:12
ditg
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:16
帖 子:852
专家分:1937
注 册:2014-4-10
收藏
得分:0 
此话有理,编译器最大。

梦想拥有一台龙芯3A-4000
2014-10-17 12:28
快速回复:出现这个报错是什么意思?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031254 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved