翻转单链表,头结点没有初始化
翻转单链表,头结点没有初始化,会导致后面无法遍历
This commit is contained in:
parent
43af376694
commit
adcbdda989
@ -74,7 +74,7 @@ struct single_list** search(struct single_list_head* head, int target)
|
|||||||
|
|
||||||
void reverse(struct single_list_head* head)
|
void reverse(struct single_list_head* head)
|
||||||
{
|
{
|
||||||
struct single_list_head tmp;
|
struct single_list_head tmp = {NULL};
|
||||||
struct single_list *elem;
|
struct single_list *elem;
|
||||||
|
|
||||||
while (!is_empty(head)) {
|
while (!is_empty(head)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user