struct person
{
int age;
char name[100];
struct person *next;
};
void delfirst(struct person **p)
{
struct person *tmp,*m;
m = (*p);
tmp = (*p)->next;
free(m);
return;
}
void delend(struct person **p)
{
struct person *tmp,*m;
tmp=*p;
while(tmp->next!=NULL)
{
tmp=tmp->next;
}
m->next=tmp;
free(tmp);
m->next = NULL;
return;
}
I am looking for two separate functions to remove the first and last elements of a linked list. Here is what I have tried. What do you suggest? It is especially difficult for me to remove the first time.
source
share