if i give if(1,0) printf("true"); else printf("false"); then it is always evaluating to false... but if i give i=(1,0)?1:0; printf("%d",i); i get 1 as output ... Actually wat does this mean??? how comma operator comes in handy in evaluating conditional expressions lyk above??? i mean its use..
sorry i=(1,0)?1:0; i get 0; all i got is that if the second argument is 1 then evaluates to true..else false.. but wat is the use of it???
It's not a lot of use, but you could argue that Code: while (i++, j++, k) { ... } is better than Code: i++; j++; while (k) { //... i++; j++; } on the grounds that it avoids code duplication.
as we know that first the condition within brakect will evaluate first, but in your case u use 2 value seperater by comma operater. the comma operater evaluated from left to right. on evaluation it find 0 as last now it keep 0 as argument of if condition. as we no that 0 means false that's why this result comes.