为什么我的vc编译器对这个函数报错,而别人的vc就不报错,是不是我的编译器有问题?
代码如下:voidMatToList(MGraphg,ALGraph*&G){inti,j,n=g.n;ArcNode*p;G=(ALGraph*)malloc(size...
代码如下:
void MatToList(MGraph g, ALGraph * &G)
{
int i, j, n = g.n;
ArcNode *p;
G = (ALGraph *)malloc(sizeof(ALGraph));
for (i = 0; i < n; i++)
{
G->adjlist[i].firstarc = NULL;
}
for (i = 0; i < n; i++)
{
for (j = n - 1; j >= 0; j--)
{
if (g.edges[i][j] != 0)
{
p = (ArcNode *)malloc(sizeof(ArcNode));
p->adjvex = j;
p->nextarc = G->adjlist[i].firstarc;
G->adjlist[i].firstarc = p;
}
}
}
G->n = n;
G->e = g.e;
return ;
}
提示就是 & 这个符号不合法,但是别的编译器就不报错 展开
void MatToList(MGraph g, ALGraph * &G)
{
int i, j, n = g.n;
ArcNode *p;
G = (ALGraph *)malloc(sizeof(ALGraph));
for (i = 0; i < n; i++)
{
G->adjlist[i].firstarc = NULL;
}
for (i = 0; i < n; i++)
{
for (j = n - 1; j >= 0; j--)
{
if (g.edges[i][j] != 0)
{
p = (ArcNode *)malloc(sizeof(ArcNode));
p->adjvex = j;
p->nextarc = G->adjlist[i].firstarc;
G->adjlist[i].firstarc = p;
}
}
}
G->n = n;
G->e = g.e;
return ;
}
提示就是 & 这个符号不合法,但是别的编译器就不报错 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询