It says 'dataIn was nullptr'.

Asked 2 years ago, Updated 2 years ago, 48 views

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?

visual-studio c++

2022-09-20 19:16

1 Answers

in the second row int* dataIn; B int* dataIn=new int; Try revising it to .


2022-09-20 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.