Comma Operator

The comma has several uses in the 'C' language. It is used:

When used as the sequential evaluation operator it causes the expressions to be evaluated in a guaranteed left to right lexical order as separated by the commas. The value of the total expression is the value of the last expression - the one to the right of the rightmost comma.

One frequent use of the comma operator is to guarantee the order (left to right) in which certain side effects or expressions will be evaluated. For example:

	while(c=getchar(),c!=EOF)
		putchar(c);

© 1991-2008 Prem Sobel. All Rights Reserved.