Falk Hueffner wrote:
> 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.
Maybe I don't understand but I don't think the code is meant
to provide means of easily changing types around. It should
help understanding how the functions work.
Regards,
Joey
--
Life is too short to run proprietary software. -- Bdale Garbee
Please always Cc to me when replying to me on the lists.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]