Witam
Mam problem z funkcją która zamienia miejscami dwa elementy z listy jednokierunkowej.
zamien()
{
struct Wezel *pomoc1;
struct Wezel *pomoc2;
struct Wezel *temp1;
temp1 = (struct Wezel*) malloc (sizeof(struct Wezel));
pomoc1 = first->next;
pomoc2 = first->next->next; //zapamiętuje wskazniki f->n i f->n->n
temp1=first;
first=first->next; // zamieniam miejscami f i f->n
first->next=temp1;
first->next=pomoc1;
first->next->next=pomoc2; //zwracam wskazniki
//wyswietlanie bazy danych:
struct Wezel *temp;
temp=first;
printf("\n");
while(temp != NULL)
{
printf("* %-15.15s * ", temp->imie);
printf("%-15.15s * \n", temp->nazwisko);
temp=temp->next;
}
}
po wykonaniu tego pokazuje mi tylko jeden wpis a drugi zostaje gdzieś zgubiony. Gdzie tutaj jest błąd?