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)), эта строка делает эту ошибку. Не понимаю, почему что случилось?sizeof (structname) - это неправильно?
#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;
}
Я исправил его и снова попытался отладить. Но это все еще делает ошибку. – user2443387
@ user2443387 Такая же ошибка или другая? И как вы отслеживали ошибку до заданных строк? – Potatoswatter
Такая же ошибка ..... – user2443387