Path: utzoo!utgpu!water!watmath!clyde!rutgers!sunybcs!boulder!tramp!swarbric From: swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) Newsgroups: comp.lang.c Subject: comma operator Message-ID: <3819@sigi.Colorado.EDU> Date: 14 Jan 88 01:48:26 GMT Sender: news@sigi.Colorado.EDU Reply-To: swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) Organization: University of Colorado, Boulder Lines: 34 I'd never used the comma operator before (except in for() statements), so today I thought I would see what it does. I did the following program. #include main() { int i=0,j; /* assignment code goes here */ printf("%d %d\n",i,j); } in place of the comment up there I put the following different things... 1) j = i,i++; 2) j = i,++i; 3) j = i; i++; 4) j = i; ++i; 5) j = i++; All five gave the answer "1 0," and (using Turbo C) they all generate the same amount of code (OBJ = 223, EXE = 5408). I assume by this that they generated the same exact code, though I was too lazy to check. So, what is the advantage of using the comma operator other than to squeeze everything on to one line? ------------------------------------------------------------------ Frank Swarbrick | "Ignorance and prejudice -- swarbric@tramp.UUCP | And fear walk and in hand." swarbric@tramp.Colorado.EDU | --RUSH ...!{hao|nbires}!boulder!tramp!swarbric