我的结构体是这样的
struct chanping_info
{ int shchl[5];
int xsl[5];
}zhengge[4];那怎么建立链表啊?而且数据已经在另一个函数里完成输入了。
如下:
struct chanping_info
{
int shchl[5];
int xsl[5];
}zhengge[4];
//定义一个新的结构体
struct StNode
{
struct chanping_info data;
struct StNode* next;
};
struct StNode* creat()
{
int i,j;
struct StNode* head,*node,*end;
head = node = NULL;
for (i=0;i<4;i++)
{
end->data = zhengge[i];
end->next = NULL;
//节点串联起来
if(head == NULL)
{
head = end;
node = head;
}else
{
node->next = end;
node = end;
}
}
return head;//返回链表头
}
你这只是不断新建end指针,可是没有把链表连接起来啊
然后函数也没有return语句啊
sizeof里面的也要加struct 啊
23行struct拿掉
你还是把这里面所有struct拿掉吧,这都不需要