| re: Confused about this question!!
Your first question was which of the expressions are illegal due to mismatched types. We already know that expressions (b), (c), and (d) must be legal since it has already been established that they all evaluate to a nonzero value.
Expression (a) is illegal because it attempts to compare a pointer to the thing being pointed at ... unless the elements of the array are of type 'void *'. Expression (a) would even evaluate to a nonzero value if each element of the array (or at least the first one) contained its own address.
By the way, the legality of (c) and (d) depend on what type of pointer variable p is declared as. These expressions are illegal if p is declared as a 'void *' because in that case there would be no way to dereference the pointer.
So ... my conclusion is that only expression (b) is definitively legal. The legality of the other expressions can't be determined without making assumptions that aren't given in the problem statement.
|