C语言这样初始化一个线性表为啥不得行?
typedefintStatus;typedefcharElemType;typedefstruct{ElemType*elem;Statuslen;}Line;intm...
typedef int Status;
typedef char ElemType;
typedef struct
{
ElemType *elem;
Status len;
}Line;
int main()
{
Line *L;
Status initList(Line *L);
}
Status initList(Line *L)
{
L->elem = (ElemType *)malloc(sizeof(ElemType)*MAX);
if(!L->elem)exit(OVERFLOW);
L->len = 0;
return OK;
} 展开
typedef char ElemType;
typedef struct
{
ElemType *elem;
Status len;
}Line;
int main()
{
Line *L;
Status initList(Line *L);
}
Status initList(Line *L)
{
L->elem = (ElemType *)malloc(sizeof(ElemType)*MAX);
if(!L->elem)exit(OVERFLOW);
L->len = 0;
return OK;
} 展开
1个回答
展开全部
你的代码...虽然是小问题,但是我也不知道该怎么解释,你参照着我给的代码修改吧..........
typedef char ElemType;
typedef struct
{
ElemType* elem;
Status len;
}Line;
Status initList(Line* L)
{
L->elem = (ElemType*)malloc(sizeof(ElemType) * MAX);
if (!L->elem)exit(OVERFLOW);
L->len = 0;
return OK;
}
int main()
{
Line* L = (Line*)malloc(sizeof(Line));
initList(L);
}
typedef char ElemType;
typedef struct
{
ElemType* elem;
Status len;
}Line;
Status initList(Line* L)
{
L->elem = (ElemType*)malloc(sizeof(ElemType) * MAX);
if (!L->elem)exit(OVERFLOW);
L->len = 0;
return OK;
}
int main()
{
Line* L = (Line*)malloc(sizeof(Line));
initList(L);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询