| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1511 人关注过本帖
标题:编译有25个错误
取消只看楼主 加入收藏
lbdsgg
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-7-20
结帖率:66.67%
收藏
已结贴  问题点数:30 回复次数:2 
编译有25个错误
源程序是这样的:
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define STACK_INIT_SIZE    100;
#define STACKINCREMENT 10;
#define ERROR 0;
#define OK 1;
typedef int SElemType;
typedef int Status;
typedef struct
{
    SElemType *base;
    SElemType *top;
    int stacksize;
}SqStack;
Status InitStack(SqStack &s)
{
    s.base=((SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));
    if(!s.base) exit(OVERFLOW);
    s.top=s.base;
    s.stacksize=STACK_INIT_SIZE;
    return OK;
}
Status push(SqStack &s,SElemType e)
{
    if(s.top-s.base)>=s.stacksize)
    {
        s.base=((SElemType *)realloc(s.base,(s.stacksize+STACKINCREMENT)*sizeof(SElenType));
        if(!s.base) exit(OVERFLOW);
        s.top=s.base+s.stacksize;
        s.stacksize+=STACKINCREMENT;
    }
    *s.top=e;s.top++
    return OK
}
Status pop(SqStack &s,int e)
{
    if(s.top==s.base) return ERROR;
    s.top--;e=*s.top;
    return OK;
}
Status destroy(SqStack &s)
{
        if(!s.base) return(OVERFLOW);
        free(s.base);
        s.base=s.top=null;
        s.stacksize=0;
        return OK;
}
void main()
{
    SqStack *s;
    int num,i,N,e;
    InitStack(s);
    printf("输入一个非负十进制数:");
    printf("输入转换为2或8或16进制:")
    while(1)
    {
        scanf("%d",&num);
        if(num<0) printf("输入错误!");
        else break;
    }
    while(1)
    {
        scanf("%d",&N);
        if(N!=2||N!=8||N!=16) printf("输入错误!");
        else break;
    }
    while(num)
    {
        push(s,num%N);
        num=num/N;
    }
    while(s.top-s.base!=1)
    {
        pop(s,e);
        printf("%d",e);
    }

}

编译后错误:
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(18) : error C2143: syntax error : missing ')' before ';'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(18) : error C2143: syntax error : missing ')' before ';'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(18) : error C2059: syntax error : ')'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(18) : error C2100: illegal indirection
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(19) : error C2065: 'OVERFLOW' : undeclared identifier
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(26) : error C2143: syntax error : missing ';' before '>='
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(26) : error C2059: syntax error : ')'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(27) : error C2143: syntax error : missing ';' before '{'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2143: syntax error : missing ')' before ';'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2143: syntax error : missing ')' before ';'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2143: syntax error : missing ')' before ';'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2059: syntax error : ')'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2065: 'SElenType' : undeclared identifier
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2059: syntax error : ')'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(28) : error C2100: illegal indirection
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(34) : error C2143: syntax error : missing ';' before 'return'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(46) : error C2065: 'null' : undeclared identifier
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(46) : error C2440: '=' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(54) : error C2664: 'InitStack' : cannot convert parameter 1 from 'SqStack *' to 'SqStack &'
        A reference that is not to 'const' cannot be bound to a non-lvalue
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(57) : error C2143: syntax error : missing ';' before 'while'
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(71) : error C2664: 'push' : cannot convert parameter 1 from 'SqStack *' to 'SqStack &'
        A reference that is not to 'const' cannot be bound to a non-lvalue
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(74) : error C2228: left of '.top' must have class/struct/union type
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(74) : error C2228: left of '.base' must have class/struct/union type
E:\Microsoft Visual Studio\COMMON\MSDev98\Bin\jinz.cpp(74) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
搜索更多相关主题的帖子: top include 源程序 
2012-12-15 22:32
lbdsgg
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-7-20
收藏
得分:0 
回复 4楼 xiaomingtutu
用数组直接来实现我之前就写好了..但是这个是数据结构的作业,我直接用数组的写好交上去应该没分数拿吧.
2012-12-16 11:37
lbdsgg
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-7-20
收藏
得分:0 
回复 7楼 yaobao
我之前已经#define ERROR 0了额
2012-12-16 11:37
快速回复:编译有25个错误
数据加载中...
 
   



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

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