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 removefront (listT *plist, int *x)
{
if (isempty(plist) == 0)
{
nodeT *temp;
*x = plist -> front -> data;
temp = plist -> front;
plist -> front = temp -> next;
free(temp);
}
}
void DFS(int wierz){
int v;
nodeT *p;
addfront(&Stos, wierz);//adding element on stack
tabzaznaczen[wierz]==1;//array of visited elements
while(Stos){
removefront(&Stos, &v);
printf("%d", v);
for(p = tabwierz[v].front; p; p = p->next){//tabwierz is array of pointers to adjecent lists
if(tabzaznaczen[p->data]==0){
addfront(&Stos, p->data);
tabzaznaczen[p->data] = 1;
}
}
}}
I used lisinit on stack and declared it global.
Its not working like it should, adding some useless integers. This is my project for school. So it is important for me, I think its like a small mistake but I cant see it.