-3
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);
}
}
這是列表。順便說一下,程序正在工作,因爲它應該只是這些警告正在打擾我向我的老師展示這件事。如果你能告訴我如何解決那些我會感到高興的事情。
什麼是** exact **錯誤消息? –
請花一些時間[閱讀如何提出好問題](http://stackoverflow.com/help/how-to-ask),並學習如何創建[最小,**完整**和可驗證示例](http://stackoverflow.com/help/mcve)。 –
函數需要一個指針'listT *',但傳遞一個指針指針'listT **',然後無限while循環就是這裏的大提示。 '&Stos'是一個指針指針。 –