struct Package_Node
{
int bar_code;
float package_weight;
Package_Node *next_packaged;
};
struct Key_Node
{
int key;
Package_Node *next_package;
};
for(int i=0; i<3; i++)
{
if(keyMain[i].next_package==NULL)
{
continue;
}
if(keyMain[i].next_package!=NULL)
{
nPointer3=keyMain[i].next_package;
nPointer4=keyMain[i].next_package;
while(nPointer3)
{
nPointer4=nPointer4->next_packaged;
delete[] nPointer3;
nPointer3=nPointer4;
}
}
}
keyMain
由给定 struct 描述的数组key_node
。
Key main 本身是一个动态数组,但为了代码的缘故,我已经将它展示为一个静态数组。
假设数组有 3 个索引长,0,1,2
每个索引包含一个单独的链表。现在我正在尝试删除每个链接列表,但似乎有些正在被删除,而有些则没有。
如何解决这个问题?