Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: printf Message-ID: <11370@smoke.BRL.MIL> Date: 21 Oct 89 22:36:43 GMT References: <543@uwm.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 12 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 ? It means what it says, namely the format string passed to printf() depends on the value of the variable a; a must be 0, 1, or 2 (corresponding to equivalent format strings "%d", "d", and ""), and in the latter two cases printf() will ignore the second argument (b). I can see using such a trick in some other cases, but this doesn't seem to be a wise use of it.