Windows has triggered a breakpoint in Graph.exe.
This may be due to a corruption of the heap, which indicates a bug in Graph.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Graph.exe has focus.
The output window may have more diagnostic information
コードにブレークポイントがなく、F12 を押していません。これは私のコードです。どうしたの?printf("sizeof edge : %d\n",sizeof(edge)); この行でエラーが発生します。なぜ何が悪いのか理解できませんか?
#include <stdio.h>
#include <stdlib.h>
typedef struct HeapStruct heap;
typedef struct edge edge;
struct edge
{
int start,end,weight;
};
struct HeapStruct {
int Capacity;
int Size;
edge *head;
};
void init(int * sets,int size);
int unionsets(int * sets, int i, int j);
int find(int * sets, int i);
void buildHeap(heap h);
edge deleteMin(heap * h);
int ends(int * sets,int size);
int main()
{
int V,E,*sets,a,startv,endv,weight;
char c,h;
edge ed;
edge * ee;
heap * Heap;
Heap = (heap*)malloc(sizeof(heap));
printf("sizeof edge : %d\n",sizeof(edge));//this line
scanf("%d",&V);
sets = (int*)malloc(sizeof(int)*V);
init(sets,V);
scanf("%d",&E);
Heap->head = (edge*)malloc(sizeof(edge)*E);//and this line
Heap->Capacity = E;
Heap->Size=0;
for(a=0; a<E; a++)
{
scanf("%d%c%d%c%d",&startv,&c,&endv,&h,&weight);
Heap->head[Heap->Size].end = endv;
Heap->head[Heap->Size++].start = startv;
Heap->head[Heap->Size++].weight = weight;
}
buildHeap(*Heap);
do
{
ed = deleteMin(Heap);
if(find(sets,ed.start)<0 || find(sets,ed.end)<0 || find(sets,ed.start) != find(sets,ed.end))
{
unionsets(sets,ed.start,ed.end);
printf("%d,%d,%d\n",ed.start,ed.end,ed.weight);
}
}
while(ends(sets,V));
scanf("%d%c%d%c%d",&startv,&c,&endv,&h,&weight);
return 0;
}