-2
我做了一个函数打印一个BTree在水平顺序没有递归的方式。运行时错误c项目
和我有一个问题找到我的错误..出现以下问题。
运行时检查失败#2 - 围绕变量'pq'的堆栈已损坏。 如果有人能说出问题在哪里,或者下次我可以如何找到它...? 如果需要,我添加完整的项目。所有的 enter link description here
void PrintTreeLevelOrder(bstree tree){ //The problem some where here.....
queue *pq = (queue*)malloc(sizeof(queue)); // is struct of : *front, *rear
node *current;// is struct of : root
create_queue(&pq);//create queue- items_num = 0,front = NULL,rear = NULL
if (tree.root == NULL) {
printf("Your Tree Is Empty:\n");
return;
}
current = tree.root;
enqueue(current, &pq);
printf("Your Tree Displayed As Queue:\n");
while ((size_of_queue(&pq))!=0) {
current = pq->front;
printf("%d ", current->data);
if (current->left != NULL)
enqueue(current->left, &pq);
if (current->right)
enqueue(current->right, &pq);
dequeue(&pq, ¤t);
}
}
你以某种方式覆盖内存,但是你可能会这样做的所有功能都不在你的例子中。 –
请制作[MCVE](强调__minimal__)。 –
我添加一个链接到所有的功能和数据结构... –