It is necessary to develop a function for swapping a given element to the end of the list, how to do this? The third day nothing happens
List.cpp
List* LoadList(char* FN, char* LN) { FILE* f = fopen(FN, "rt"); if (!f) { cout << " "; return NULL; } char st[Max_ch]; fgets(st, Max_ch, f); List* lst = CreateList(LN, st); while (fgets(st, Max_ch, f)) { AddHead(lst, st); } return lst; } // ?????Перестановка????? void Per(char* Inf) { } /*-Создать элемент списка-*/ Itm* CrItm(int Id, char* Inf) { Itm* t = new Itm; t->next = t->prev = NULL; t->id = Id; strcpy(t->Info, Inf); return t; } /*-Создать список(Заголовок, информация)-*/ List* CreateList(char* Name, char* Inf) { List* lst = new List; strcpy(lst->Name, Name); lst->getId = 1; lst->begin = CrItm(lst->getId, Inf); lst->end = lst->begin; return lst; } /*-Добавить строку-*/ Itm* AddHead(List* lst, char* Inf) { lst->cur = CrItm(++lst->getId, Inf); lst->begin->prev = lst->cur; lst->cur->next = lst->begin; lst->begin = lst->cur; return lst->begin; } /*-Вывести список-*/ void ViewLst(List* lst) { printf(" %s \n", lst->Name); lst->cur = lst->begin; while (lst->cur) { printf("%i: %s \n", lst->cur->id, lst->cur->Info); lst->cur = lst->cur->next; } } /*---------------------------------------------------------------------*/ void DelHead(List* lst) { if (lst->begin == lst->end) { DelLst(lst); } else { lst->cur = lst->begin; lst->begin->prev = NULL; delete lst->cur; } } void DelLst(List* lst) { while (lst->begin != lst->end) { DelHead(lst); } delete lst->begin; delete lst; } void ViewLstBk(List* lst) { printf(" %s \n", lst->Name); lst->cur = lst->end; while (lst->cur) { printf("%i: %s \n", lst->cur->id, lst->cur->Info); lst->cur = lst->cur->prev; } } List.h
struct Itm { int id; char Info[Max_ch]; Itm *next, *prev; //Начало и конец списка }; struct List { char Name[20]; int getId; Itm * begin, *cur,*end; }; List* CreateList(char* Name, char* Inf); Itm* AddHead(List* lst, char* Inf); Itm * CrItm(int id); void ViewLst(List* lst); void DelHead(List* lst); void DelLst(List* lst); void ViewLstBk(List* lst); void Per(List* lst); List* LoadList(char* FN, char* LN);