当我尝试编译我得到了预期的*,但是参数类型是**,并警告传递参数兼容的指针类型

问题描述:

listT *Stos; 
void DFS(int wierz) { 
    int v; 
    nodeT *p; 
    addfront(&Stos, wierz); 
    tabzaznaczen[wierz] = 1; 
    while (Stos) { 
    removefront(&Stos, &v); 
    printf("%d\n", v); 
    for (p = tabwierz[v].front; p; p = p->next) { 
     if (tabzaznaczen[p->data] == 0) { 
     addfront(&Stos, p->data); 
     tabzaznaczen[p->data] = 1; 
     } 
    } 
    } 

当我改变声明listT Stos;其揭示的错误:需要标量时使用了结构类不值。然后当我改变到while(&Stos)我\而去无限。当我尝试编译我得到了预期的*,但是参数类型是**,并警告传递参数兼容的指针类型

typedef struct nodeTAG{ 
int data; 
struct nodeTAG *next; 
}nodeT; 

typedef struct listTAG{ 
nodeT *front; 
nodeT *end; 
}listT; 


void listinit (listT *plist) 
{ 
plist -> front = NULL; 
plist -> end = NULL; 
} 

int isempty (listT *plist) 
{ 
if (plist -> front == NULL) 
return 1; 
else return 0; 
} 

void addfront (listT *plist, int x) 
{ 
nodeT *temp; 
temp = (nodeT*)malloc(sizeof(nodeT)); 
temp -> data =x; 

if (plist -> front == NULL) 
{ 
temp -> next = NULL; 
plist -> front = temp; 
plist -> end = temp; 
} 
else 
{ 
temp -> next = plist -> front; 
plist -> front = temp; 
} 
} 

void addend (listT *plist, int x) 
{ 
nodeT *temp; 
temp = (nodeT*)malloc(sizeof(nodeT)); 
temp -> data = x; 

if (plist -> front == NULL) 
{ 
temp -> next = NULL; 
plist -> front = temp; 
plist -> end =temp; 
} 
else 
{ 
temp -> next = NULL; 
plist -> end -> next = temp; 
plist -> end = temp; 
} 
} 

void removefront (listT *plist, int *x) 
{ 
if (isempty(plist) == 0) 
{ 
nodeT *temp; 
*x=plist->front->data; 
temp = plist -> front; 
plist -> front = temp -> next; 
free(temp); 

} 
} 

这是列表。顺便说一下,程序正在工作,因为它应该只是这些警告正在打扰我向我的老师展示这件事。如果你能告诉我如何解决那些我会感到高兴的事情。

+0

什么是** exact **错误消息? –

+3

请花一些时间[阅读如何提出好问题](http://*.com/help/how-to-ask),并学习如何创建[最小,**完整**和可验证示例](http://*.com/help/mcve)。 –

+2

函数需要一个指针'listT *',但传递一个指针指针'listT **',然后无限while循环就是这里的大提示。 '&Stos'是一个指针指针。 –

很高兴看到所用函数的函数原型,但看起来您需要一个指向您的列表指针的指针,以便当removefront删除第一个节点并将指针重新分配给新头时,它不会丢失返回时。

这是关于链接列表的精彩教程:http://www.learn-c.org/en/Linked_lists

+0

我增加了函数。 –