bro hasn't been initialized yet. I mean bro itself. Bro
while(bro->nextsibling = p)
改为
while(bro->nextsibling == p)
或者
while(bro->nextsibling != p)
bro =new ...
其实,你可能时当局者迷了
bro = p->father->firstchild;
这里,你将father 的firstchild 给了 bro。
当你有没有想过p->father 不为 NULL,但是其 firstchild 确定不为NULL 吗?
如果firstchild 为NULL,那么bro 也为NULL,那这样while 循环就不能用bro 去->