powerful expressions

King Su wen-king at cit-vax.Caltech.Edu
Sat Dec 2 17:14:29 AEST 1989


References
Sender: 
Reply-To: wen-king at cit-vax.UUCP (Wen-King Su)
Followup-To: 
Distribution: 
Organization: California Institute of Technology
Keywords: 

While we are discussing styles, let's talk about simple expressions
that do a lot things.

	struct QUEUE { struct QUEUE *next;
		       <... other fields in the structure ...> } ;

	struct QUEUE *qhead, *qtail, *qnew;

I have concocted the following single expression that appends 'qnew' to
the queue formed by 'qhead' and 'qtail'.  The queue is null terminated,
'qhead' points to the first element of the queue, and 'qtail' points to
the last element of the queue:

	((qhead) ? (qtail = qtail->next = qnew)
		 : (qtail = qhead       = qnew))->next = 0;

Do you have any favorite C-expressions that you would like to share?

-- 
/*------------------------------------------------------------------------*\
| Wen-King Su  wen-king at vlsi.caltech.edu  Caltech Corp of Cosmic Engineers |
\*------------------------------------------------------------------------*/



More information about the Comp.lang.c mailing list