-2

こんにちは、VS 2010 でこのコードを実行しようとすると、クラッシュして次のように表示されます。

これは、ヒープの破損が原因である可能性があります。これは、TEST_5.exe または読み込まれた DLL のバグを示しています。

これは、TEST_5.exe にフォーカスがあるときにユーザーが F12 キーを押したことが原因である可能性もあります。

出力ウィンドウには、より多くの診断情報が表示される場合があります。プログラム '[4620] TEST_5.exe: Native' はコード 0 (0x0) で終了しました。

そして、ボーランドCコンパイラで同じクラッシュが発生しましたが、dev 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");
}
4

1 に答える 1