sll_remv.c
来自「《c与指针》书的代码 是我学习这本书时候敲出来的」· C语言 代码 · 共 37 行
C
37 行
/*
** Remove a specified node from a singly linked list. The first
** argument points to the root pointer for the list, and the second
** points to the node to be removed. TRUE is returned if it can be
** removed, otherwise FALSE is returned.
*/
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "singly_linked_list_node.h"
#define FALSE 0
#define TRUE 1
int
sll_remove( struct NODE **linkp, struct NODE *delete )
{
register Node *current;
assert( delete != NULL );
/*
** Look for the indicated node.
*/
while( ( current = *linkp ) != NULL && current != delete )
linkp = ¤t->link;
if( current == delete ){
*linkp = current->link;
free( current );
return TRUE;
}
else
return FALSE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?