Martin Schulze <[EMAIL PROTECTED]> writes:

> Falk Hueffner wrote:
>> Just another minor suggestion, the example code uses:
>> 
>>             qsort(months, nr_of_months, sizeof(struct mi), compmi);
>> [...]
>>                  res = bsearch(&key, months, nr_of_months,
>>                             sizeof(struct mi), compmi);
>> 
>> I think it would be better to use
>> 
>>             qsort(months, nr_of_months, sizeof *months, compmi);
>> [...]
>>                  res = bsearch(&key, months, nr_of_months,
>>                             sizeof *months, compmi);
>> 
>
> I don't think so.  From the declaration months is of type
> struct mi[].  Thus, the size of each element is sizeof(struct mi),
> logically.

That's true. However, that code is less robust, since changing the
type of *months now requires to change two places, and verifying the
correctness of the call requires you to look up the declaration.

-- 
        Falk



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to