QUEUE* Node = createQueue();
int* dataIn;
int* dataOut;
void BreadthFirstprint(Tree* tree) {
if (tree) {
*dataIn = tree->data;
enqueue(Node, &dataIn);
BreadthFirstprint(tree->left);
BreadthFirstprint(tree->right);
}
while (!emptyQueue(Node))
{
dequeue(Node, (void**)&dataOut);
printf("[ %d ] ", *dataOut);
}}
There's an error here. I want to put tree->data
into the queue and output it, but dataIn
is nullptr
. How can we solve this?
in the second row
int* dataIn;
B
int* dataIn=new int;
Try revising it to .
© 2024 OneMinuteCode. All rights reserved.