0
点赞
收藏
分享

微信扫一扫

runtime error: member access within null pointer of type ‘struct ListNode‘错误

大漠雪关山月 2022-01-25 阅读 47

LeetCode203错误分析:

(3条消息) LeetCode:runtime error: member access within null pointer of type 'struct ListNode'错误_时间有泪-CSDN博客

如上述博客方法进行更改后执行错误,最后的更改方式:

if(p==NULL){
   return head;
}
while(p->next!=NULL){
     if(p->next->val==val){
        q=p->next;
        p->next=q->next; 
        delete q;
     }
     else{
        p=p->next;
     }
}

期望的改正方式:但改正后依旧如题目报错

while(p->next!=NULL&&p!=NULL){
     if(p->next->val==val){
        q=p->next;
        p->next=q->next; 
        delete q;
     }
     else{
        p=p->next;
     }
}
举报

相关推荐

0 条评论