Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!rpi!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: printf Message-ID: <1325@crdos1.crd.ge.COM> Date: 23 Oct 89 14:21:21 GMT References: <543@uwm.edu> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Distribution: na Organization: GE Corp R&D Center Lines: 19 In article <543@uwm.edu>, zhao@csd4.csd.uwm.edu (T.C. Zhao) writes: | I recently came across a piece of c code:(both a and b are integers) | printf("%d"+(a),b); | in passes compiler without any problem, what does this code mean ? I have no idea what it means, I can explain what it does... "%d"+a is a form of address plus integer expression notation. It evaluates to the *address* of the a'th character in the format. It also could be written as &("%d"[a]) if you wish. I have no idea why anyone would do this, and if a ever has a value other than zero or one when this executes it will be non-portable. For a==0 the value of b will be printed, while for a==1 the character d will be printed. This is either a typo or some really obscure C. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon