Pointers on pointers.

Doug Gwyn gwyn at smoke.brl.mil
Sat Apr 6 10:12:48 AEST 1991


In article <1991Apr5.173843.2435 at bnlux1.bnl.gov> reilly at bnlux1.bnl.gov (kevin reilly) writes:
>If dataType1 is known in advance as containing only ints can I do the
>following:
>declaration: void FUNC1(int *input);
>usage: FUNC1(&strType.data1);
>as opposed to the more correct procedure:
>declaration: void FUNC1(dataType *input);
>usage: FUNC1(&strType.data1);

If representation of pointer-to-int happens not to use the same scheme
as representation of pointer-to-structure, then using the incorrect
type would probably result in a malfunction.

You could also invoke the function with argument &strType.data1.x, where
"x" is the name of the first (int) member of the structure.

A more general comment is that there appears to be an imperfect
implementation of data abstraction underlying this example.



More information about the Comp.lang.c mailing list