I have the following functions, an initializeHeap function which takes in no arguments and outputs a Heap struct which I have defined. And an insertNode function which takes in a pointer to a heap struct and the number to be added to the heap. I call them in the main function as such:
h = initializeHeap();
Heap *p = *h;
insertNode(p,5);
insertNode(p,7);
insertNode(p,3);
insertNode(p,2);
I get this error when trying to do this:
error: indirection requires pointer operand
Any ideas? I can post more code if needed.
The struct Heap and function initializeHeap() are as follows:
typedef struct node{
int data;
}Node;
typedef struct heap{
int size;
Node *dataArray;
}Heap;
Heap initializeHeap(){
Heap heap;
heap.size = 0;
return heap;
}
Change:
Heap *p = *h;
to
Heap *p = &h;
h
is a Heap
structure object, use &
operator to get a pointer to the structure object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With