问题描述
- 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 FilesMicrosoft Visual StudioMyProjectsDome2Dome2.cpp(14) : error C2143: syntax error : missing ';' before ''
C:Program FilesMicrosoft Visual StudioMyProjectsDome2Dome2.cpp(14) : fatal error C1004: unexpected end of file found
解决方案
#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);
}
时间: 2024-11-08 20:08:24