Re: [NEWBIE] question

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 04/03/01


On Wed, 4 Apr 2001, Mysidia wrote:

>     Sample use:
>
>     foo = (0 ? a : c,b)
>
>     is the same as foo = c

No.  The value of the expression c,b is b, thus the value of that entire
expression is b, with the side-effect of binding the value of b to the
variable foo.  Throwing in the comma operator there seems sort of weird,
since you're trying to demostrate a simple use of the conditional
expression, not of the weird comma operator in C.  Suffice it to say,
however, that the comma operator always evaluates to the rightmost
subexpression:

  printf("%d\n", (1,2,3,4,5,6,7));

prints

  7

It's not particularly useful to know this.


-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST