链表(插入) [英] linked list (Insert)

查看:70
本文介绍了链表(插入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我一直遇到问题:

展开 | 选择 | Wrap | 行号

解决方案

< blockquote class =post_quotes>
pre = pre-> NextVehicule;


if(pre-> NextVehicule == NULL)// **** THIS ONE ****



如果pre为NULL,您将崩溃。


在pre-> NextVehicule尝试使用之前检查pre为NULL。


此外,如果pre-> nextVehicule为NULL(你的if ...声明检查),然后就没有pre-> nextVehicule-> data_vehicule,所以你也会在这里崩溃。


但我需要达到状态,以便在最后插入!


why i keep having problem in thhis line:

Expand|Select|Wrap|Line Numbers

解决方案

pre = pre->NextVehicule;

if(pre->NextVehicule == NULL) // ****THIS ONE****

You will crash if pre is NULL.

Check pre for NULL before trying to use it in pre->NextVehicule.


Additionally, if pre->nextVehicule is NULL (which your if...statement checks), then there will be no pre->nextVehicule->data_vehicule, so you will crash here as well.


but i need to reach that status in order to insert at the end!


这篇关于链表(插入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆