Queue item:
typedef struct List{ int key; char name[30]; struct List * next; }tList; Function to exchange items
void elements_swap(tList * elem1,tList * elem2){ tList *n_bufer,*prev1,*prev2,*cp = begin_line; while(cp!= NULL){ if(cp->next == elem1){ prev1 = cp; } if(cp->next == elem2){ prev2 = cp; } cp = cp->next; } prev1->next = elem2; prev2->next = elem1; n_bufer = (tList*)elem1->next; elem1->next = elem2->next; elem2->next = n_bufer; } The problem is that comparisons and assignment of pointers of different types occur, i.e. crash occurs at this moment prev2->next = elem1;
Is there a solution other than how to remove typedef ?
prev2, say, zero. Becausetypedefnothing to do with it. Yes, and add how youbegin_linedefined (why, for example, you do not pass this value as an argument). - Harrybegin_linepoints toelem1orelem2? - Harry