error C2100: illegal indirection

wd9053 2010-03-25 09:48:33
不明白为什么代码会报错,求教

#include <stdio.h>
#include <stdlib.h>

#define ElemType char
typedef struct SqList
{
ElemType* elem;
int length;//number of elements
int listsize;//the capacity of list
};

#define SqListSize 100;
void InitList(SqList &list);
void DestroyList(SqList &list);

void DestroyList(SqList &list)
{
free(list.elem);
}

void InitList(SqList &list)
{
list.listsize = SqListSize;
list.elem = (ElemType*)malloc(SqListSize * sizeof(ElemType));//////?
}

void main()
{
getchar();
}
...全文
251 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuzl32 2010-03-25
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <stdlib.h>

#define ElemType char

typedef struct SqList
{
ElemType* elem;
int length;//number of elements
int listsize;//the capacity of list
} SqList;

#define SqListSize 100 //2.

void InitList(SqList &list);
void DestroyList(SqList &list);

void DestroyList(SqList &list)
{
free(list.elem);
}

void InitList(SqList &list)
{
list.listsize = SqListSize;
list.elem = (ElemType *)malloc(SqListSize * sizeof(ElemType));
}

void main()
{
getchar();
}
柯本 2010-03-25
  • 打赏
  • 举报
回复
1.
typedef struct
{
ElemType* elem;
int length;//number of elements
int listsize;//the capacity of list
} SqList; ////typedef 写反了
2.
#define SqListSize 100
后面不能有";"号

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧