[plug] C Programmers Only

Greg Mildenhall greg at networx.net.au
Mon Mar 15 15:42:52 WST 1999


On Mon, 15 Mar 1999, David Campbell wrote:
> > If I have a struct such as:
> > struct call
> > 	{
> > 	int seq;
> > 	};
> > Then I malloc() one.
> > How do I pass by reference one of the component of the struct?
> > ptr = (struct list_node *) malloc(sizeof(struct list_node))
> > sscanf(buf, "%d", ????)
> sscanf(buf, "%d", &ptr->seq);

Since it is relevant to general C coding, it should be noted that "&" will
turn a variable into a reference in any situation, not just in the above
context. If foo is a variable, &foo is a pointer to it.
Other uses for '&' are not fit for publication on a public list.

-Greg Mildenhall



More information about the plug mailing list