Char clinklistdelete (circularlinklist &cl) { //delete footer element if (Cl->next = = CL) { printf ("List is Empty!\n "); return 0; } else { circularlinklist p=cl->next; char e; e=cl->data; while (p->next! = CL) {p=p->next;} Looking for the tail pointer before a position p->next=cl->next; Free (CL); cl=p; cl->next->data--; return e; }}
The first approach: using the C + + compiler
The second method: Use the pointer to resolve, instead:
Char clinklistdelete (circularlinklist *cl) { //delete footer element if ((*cl)->next = = *cl) { printf ("List is Empty!\n "); return 0; } else { circularlinklist p= (*CL)->next; char e; E= (*CL)->data; while (p->next! = *cl) {p=p->next;} Looking for the tail pointer before a position p->next= (*CL)->next; Free (*CL); *cl=p; (*CL)->next->data--; return e; }}
Learning experience: C language, reference types in formal parameters, two ways to compile with GCC