-2
私は、レベル順で再帰的な方法でBTreeを印刷する関数を作成します。実行時エラー - プロジェクト
私は間違いを見つけるのに問題があります。次の問題が表示されます。
ランタイムチェック失敗#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__に重点を置く)を作ってください。 –
すべての関数とデータ構造体へのリンクを追加します。 –