I have a structure
struct abc
{
struct xyz *ptr1; int *a;
};
struct xyz
{
int *b;
enum __boolean *filter;
};
here
enum __boolean
{
false = 0;
true = 1;
};
I have declared a pointer to struct abc *ptr and have done a malloc,can any one pls tell me how to access the value in the enum, i want to assign the value.
I have done a malloc of all the structure
ptr->ptr1->filter = ?
how to access the enum, i want to put the value zero there.
Since the struct field
filteris a pointer to an enum, you need to dereference:This is no different just because
memberis an enum, it would be exactly the same for any other directly assignable (“scalar”) type such asintor whatever.You say you want to put the value “zero”, but since the type of
filteris an enumeration, I guess you meantfalse.Note also that in C99, we have
stdbool.h>which givesboolandtrueandfalse. It’s best to use them, and not do anenum, if you can.