C Tutorial/Operator/Comma Operator — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
(нет различий)
|
Текущая версия на 13:32, 25 мая 2010
Comma operator
You can combine multiple expressions in a single expression using the comma operator.
<source lang="cpp">#include<stdio.h>
main(){
int i,j,k; k = (i = 4, j = 5); printf("k = %d",k);
}</source>
k = 5
Comma operator can return a value.
Comma operator returns the value of the rightmost operand.
<source lang="cpp">#include<stdio.h>
main(){
int i, j; printf("%d",(i = 0, j = 10));
}</source>
10