您好我试试这个于2010年VS运行这段代码,我也得到崩溃的告诉我说:用C双向链表崩溃
这可能是由于堆的腐败,这表明在TEST_5的错误.exe或任何已加载的DLL。
这也可能是由于用户在TEST_5.exe有焦点时按下F12。
输出窗口可能有更多诊断信息。 程序'[4620] TEST_5.exe:Native'已退出,代码为0(0x0)。
和我在borland c编译器上有同样的崩溃,但在开发cpp的工作。 所以这是我的代码请帮助
#include <stdio.h>
#include <stdlib.h>
struct node{
int ID;
int active;
int loop_time;
float c;
int a;
struct node *prev,*next;
};
struct node *new_node(struct node *p)
{
struct node *temp,*prev;
if(p==NULL)
{
p=(struct node*)malloc(sizeof(struct node*));
p->prev=NULL;
p->next=NULL;
return p;
}
if(p!=NULL)
{
temp=p;
while(temp!=NULL)
{
prev=temp;
temp=temp->next;
}
temp=(struct node*)malloc(sizeof(struct node*));
temp->prev=prev;
temp->next=NULL;
prev->next=temp;
return temp;
}
return 0;
}
void main()
{
struct node *force1=NULL;
//=============================
force1=new_node(force1);
force1->ID=11;
force1->active=11;
force1->loop_time=0;
//==============================
force1=new_node(force1);
force1->ID=11;
force1->active=11;
force1->loop_time=0;
//==============================
printf("END\n");
system("pause");
}
它在哪里崩溃?调试时发现了什么? – Kunal