2 u010407743 u010407743 于 2014.02.27 22:32 提问

c++ 数据结构问题,有点低级但我是初学者望大神帮帮忙

#include "stdafx.h"
#include
#define SIZE 100
#define TRUE 1
#define FALASE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef Datetype char
typedef struct{
Datatype *elem;
int length;
int size;
}sqlist;
Status Initlist(sqlist *l)
{
l->elem=(Datatype *)malloc(SIZE*sizeof(Datatype));
if(!l->elem)
exit(OVERFLOW)
l->length=0;
l->size=SIZE;
return OK;
}
void main()
{
splist l;
Initlist(*l);
}
这个程序有问题
报错error C2236: unexpected 'struct' '__unnamed'
C:\Program Files\Microsoft Visual Studio\MyProjects\Dome2\Dome2.cpp(14) : error C2143: syntax error : missing ';' before ''
C:\Program Files\Microsoft Visual Studio\MyProjects\Dome2\Dome2.cpp(14) : fatal error C1004: unexpected end of file found

1个回答

VisualEleven
VisualEleven   Ds   Rxr 2015.01.04 18:39

#define SIZE 100
#define TRUE 1
#define FALASE 0

typedef enum Status
{
    OK = 1,
    ERROR1 = 0,
    INFEASIBLE = -1,
    OVERFLOW = -2,
};


typedef char Datatype;

typedef struct
{
    Datatype *elem;
    int length;
    int size;
}sqlist;

Status Initlist(sqlist *l)
{
    l->elem=(Datatype *)malloc(SIZE*sizeof(Datatype));
    if(!l->elem)
        exit(OVERFLOW);
    l->length=0;
    l->size=SIZE;
    return OK;
}
void main()
{
    sqlist l;
    Initlist(&l);
}
Csdn user default icon
上传中...
上传图片
插入图片