Addresses of parameters

Barry Margolin barmar at think.COM
Fri Oct 28 05:16:32 AEST 1988


In article <35664 at XAIT.Xerox.COM> g-rh at XAIT.Xerox.COM (Richard Harter) writes:
>taking the address of a parameter is not a useful kind of thing to do.

Why not?  You are assuming that taking the address of a variable is
only used when you plan to use it as an output parameter for a
function.  There are, however, functions that take pointers to input
data.  A good example is write(), which takes a pointer to the data to
be written.  Suppose you write a function that takes a structure as a
parameter, and it wants to write that structure to a file, using
write().  It will either take the address of the structure parameter,
or it will have to make an automatic copy of the structure and take
the address of that.  I think taking the address of the parameter is
preferable to making ANOTHER copy of the structure (the first copy has
to be made during the calling sequence of the function).

Barry Margolin
Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list