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;
}
}
}
And when i change declaration to listT Stos;
its revealing error: used struct tpye value when scalar is required. And then when i change to while(&Stos)
i\while goes to infinity.
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);
}
}
This is the list. By the way program is working as it should just those warnings are bothering me to show this to my teacher. If u could tell me how to fix those i would be pleased.