だから私はこれを追跡し、コメントされたセクションが私に問題を与えています.私はリンクリストの最後にいます.nullptrを新しいノード*qに変更したいのですが、新しく追加されたノード。
Node* append( int x, Node* p ) {
Node *q=new Node;
Node *head=p;
if(p==nullptr) {
p=q;
q->value=x;
}
while (p!=nullptr) {
p=p->next;
}
//arrived at NULL ptr
q=p->next; //<---this is causing my program to crash.
q->value=x;
q->next=nullptr;
return head;
}