typedef struct link_s
{
struct link_s *next;
int data;
}link_t;
//虽然很简单,却很有意义
int delete_node(link_t **head, int data)
{
link_t **cur = head;
link_t *free_node = NULL;
while(NULL != *cur)
{
if((*cur)->data == data)
{
free_node = *cur;
*cur = free_node->next;
free(free_node);
free_node = NULL;
}
cur = &((*cur)->next);
}
return 0;
}
{
struct link_s *next;
int data;
}link_t;
//虽然很简单,却很有意义
int delete_node(link_t **head, int data)
{
link_t **cur = head;
link_t *free_node = NULL;
while(NULL != *cur)
{
if((*cur)->data == data)
{
free_node = *cur;
*cur = free_node->next;
free(free_node);
free_node = NULL;
}
cur = &((*cur)->next);
}
return 0;
}