I am looking for an error in my code (in C) and I am not finding anything.
I've looked on many blogs and tried many things that were advised but nothing helped.
I've coded that :
typedef struct Account_t *Account;
struct Account_t {
Customer customer;
Realtor realtor;
Offer offer;
};
while Realtor, Customer and Offer are well defined and included with a .h file. I am getting an error that says "dereferencing pointer to incomplete type 'struct Account_t' " when I write:
Account account = malloc(sizeof(*account));
Please help me find the problem !
I'd say, you have to do something like this:
Account account = (Account)malloc(sizeof(*account));
I tried your code out. And I had similar issue as you.
The problem is with your code, when you allocate the structure in the heap, the returned value is wrong assigned, because the malloc returns a pointer.
my code looks like this:
And second thing: As type definition I do not define the structure as a pointer.
Try this, I hope this information useful!