创建一个顺序表后,想要直接给每一个元素赋值,但是会出现错误,问题出现在代码的最后几行。
你的elem不是数组,怎么要用下标去访问?
我可以运行,是不是其他地方写错了
这是一个测试的例子
struct a
{
int a1;
};
struct b
{
struct a *b1;
};
struct b theb;
struct b *p = &theb;
//theb.b1 = malloc(sizeof(struct a) * 3);
p->b1 = malloc(sizeof(struct a) * 3);
p->b1[0].a1 = 1;
printf("%d\r\n", p->b1[0].a1);
请显示全部代码啊