Path: utzoo!attcan!uunet!lll-winken!ames!killer!texbell!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: Comma Operator Keywords: order of evaluation, comma operator, function call Message-ID: <8759@alice.UUCP> Date: 14 Jan 89 19:55:25 GMT References: <922@quintus.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 31 In article <922@quintus.UUCP>, nair@quintus writes: > What should this print? > > int x, y; > printf("%d %d\n", (x = 1, y = 2), x, y); Whatever the compiler wants to print. > Shouldn't it be equivalent to: > > int a, x, y; > a = (x = 1, y = 2); > printf("%d %d %d\n", a, x, y); No. The arguments of printf are not required to be evaluated in any particular sequence. > Is there God? Why am I here? :-) :-) The first question is too difficult for comp.lang.c The second can be divided into two parts. Part 1: `Why?' This is an extremely difficult question as well, so it is left as an exercise for the reader. Part 2: `Am I here?' Answer: yes. -- --Andrew Koenig ark@europa.att.com