Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!cg-atla!fredex From: fredex@cg-atla.UUCP (Fred Smith) Newsgroups: comp.lang.c Subject: Re: printf Message-ID: <7799@cg-atla.UUCP> Date: 22 Oct 89 01:18:13 GMT References: <543@uwm.edu> Reply-To: fredex@cg-atla.UUCP (Fred Smith) Distribution: na Organization: Agfa Compugraphic Division Lines: 15 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 ? "%d" evaluates to a POINTER to a char, i.e., char *. It is legal to add an integer to a pointer, so if one assumes that (a) represents an integer value, this would pass the value of the pointer, offset by the value of the integer expression a, as the first parameter of the printf call. God alone knows WHY anyone would want to do that, but, yes, it does appear to be legal C. Fred