VC6,C语言,谁帮忙看看这个语法错误怎么回事?小弟没分,感激不尽

#include<stdio.h>#include<stdlib.h>#defineSTACK_INIT_SIZE100#defineOVERFLOW-2#defineO... #include <stdio.h>
#include <stdlib.h>
#define STACK_INIT_SIZE 100
#define OVERFLOW -2
#define OK 1
#define ERROR 0
typedef struct
{
char alp;
}ElemType;
ElemType L;
typedef struct NodeType
{
ElemType data;
NodeType *next;
}NodeType;
typedef struct
{
NodeType *top;
NodeType *base;
int stacksize;
}Stack;
Stack S;
int InitStack(Stack &S)
{
S.base=(NodeType *)malloc(STACK_INIT_SIZE * sizeof(NodeType));
if(!S.base) exit (OVERFLOW);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
return OK;
}
int StackEmpty(Stack S)
{
if (S.top==S.base)
return OK;
else return ERROR;
}
int Push(Stack &S,ElemType em)
{
NodeType *p;
(*p).data=em;
(*p).next=S.top;
S.top=p;
S.stacksize++;
return OK;
}
int Pop(Stack &S,ElemType &em)
{
if(S.base==S.top)return ERROR;
else
{NodeType *p;
p=S.top;
S.top=S.top->next;
em=p->data;
S.stacksize--;
return OK;
}
void main()
{
int m,i,j;
int k=0;
int n=0;
char put_arr[];
char arr[]={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z};
printf("Please enter the depth of the stack\n");
scanf("%d",&m);
do{
for(i=0,i<=m;i==)
{
L.alp=arr[k];
k++;
Push(S,L);
return OK;
}
while(!StackEmpty(S))
{
for(j=0;j<=m;j++)
{ Pop(S,&L);
put_arr[n]=L.alp;
n++;
return OK;
}
}
}while(n<26);
printf("the result is\n");
for(i=0;i<=25;i++)
printf("&c ",put_arr[i]);
}
--------------------Configuration: 01 - Win32 Debug--------------------
Compiling...
01.cpp
D:\VC6.0++\MSDev98\MyProjects\栈作业\01.cpp(59) : error C2601: 'main' : local function definitions are illegal
D:\VC6.0++\MSDev98\MyProjects\栈作业\01.cpp(94) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

01.obj - 1 error(s), 0 warning(s)
展开
 我来答
hunnully
2012-04-03 · TA获得超过224个赞
知道答主
回答量:173
采纳率:0%
帮助的人:142万
展开全部
void 是无返回值得函数
但是你却有带值的return语句
所以错了~
更多追问追答
追问
把return删了还是一样啊?求指导。。
追答
local function definitions are illegal
意思是本地函数的定义是非法的。
你用的什么编译器?
有些编译器不允许把 main函数定义为void
比如 DEV C++。
你把main函数改为int。然后在最后面加上return 0; 试试
roaming_sheep
2012-04-03 · TA获得超过699个赞
知道小有建树答主
回答量:589
采纳率:0%
帮助的人:715万
展开全部
大括号不匹配。

int Pop(Stack &S,ElemType &em)
{
if(S.base==S.top)return ERROR;
else
{NodeType *p;
p=S.top;
S.top=S.top->next;
em=p->data;
S.stacksize--;
return OK;
}

其它错还有:
char put_arr[]; //数组没定义大小

char arr[]={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}; //数组初始化错误,字符常量要用单引号 'a'
更多追问追答
追问
有这个大括号啊T_T
追答
有 两个 { ,但只有1个 }
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zxk1004
2012-04-03 · 超过24用户采纳过TA的回答
知道答主
回答量:51
采纳率:0%
帮助的人:62.1万
展开全部
楼上的,你没看程序吧,他的void main()上面的int Pop(Stack &S,ElemType &em)函数缺少右花括号} ,所以提示定义函数错误。加上括号后再改错吧,错误还很多
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式