You need to compare the members of the struct yourself, like this:
if(d[0].a ==d[1].a)
structs are not valid operands for equality(==
), the operands have to be an arithmetic type or a pointer. We can see this from the draft C99 standard section 6.5.9
Equality operators:
One of the following shall hold:
- both operands have arithmetic type
- both operands are pointers to qualified or unqualified versions of compatible types;
- one operand is a pointer to an object or incomplete type and the other is a pointer to a qualified or unqualified version of void; or
- one operand is a pointer and the other is a null pointer constant.