I assume this code:
while(again)
build(head);
Was meant to be (calling again
instead of comparing it to zero):
while(again())
build(head);
Either way, the first time through the loop head
is NULL. But build
goes ahead and uses it anyway:
head->next = new node;
Here, using next
will produce a segment fault because head
is NULL. You are accessing an invalid location in memory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…