struct accessing

Leslie Mikesell les at chinet.chi.il.us
Thu Jul 6 06:40:51 AEST 1989


In article <18255 at usc.edu> blarson at basil.usc.edu (bob larson) writes:

>>There is a special dispensation, though: "If a pointer to a structure
>>is cast to the type of a pointer to its first member, the result
>>refers to the first member".  [8.3]

>There is at least one current (non-ansi) compiler that does not do this
>currently...

Is it possible to use the bsearch(), tsearch(), etc., library routines
for data in structs if a pointer to the struct cannot be cast to a
character pointer?  Alternatively, given a pointer to an element of
a struct, is it possible to deduce the base address (I assume this would
require pointer subtraction and thus be illegal)?

Les Mikesell



More information about the Comp.lang.c mailing list