今天,调试时候发生这个错误,算法逻辑都检查了,没有问题,看来是语法问题导致的。
我的指针数组的初始化方式有误,sizeof应该输入AdjList(*)[20],而我写的是sizeof(AdjList(*))*20
正确的初始化
AdjList (*list)[20] = (AdjList(*)[20])malloc(sizeof(AdjList(*)[20]));
数据结构定义如下
typedef struct _edge
{
int src,dst,dist;
struct _edge *next;
}Edge;
typedef struct _head
{
struct _edge *head;
struct _edge *tail;
}AdjList;