Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site datagen.UUCP Path: utzoo!linus!decvax!harpo!floyd!cmcl2!rocky2!datagen!mrm From: mrm@datagen.UUCP Newsgroups: net.lang.c Subject: Re: %r in printf Message-ID: <36@datagen.UUCP> Date: Thu, 13-Oct-83 13:11:51 EDT Article-I.D.: datagen.36 Posted: Thu Oct 13 13:11:51 1983 Date-Received: Fri, 14-Oct-83 21:52:56 EDT Organization: Data General Dist. Systems, Westborough, MA Lines: 23 I was told by a friend that used to work at Bell Labs, that %r was undocumented, but in the early versions of UNIX (tm). It was removed around the time, v7 went out. The way he rememebered it worked was the way I implemented it for AOS/VS C, put I have heard from others that the DECUS way was the actual way it was implemted. For the record, the way AOS/VS C implements %r is to consider the next argument as a byte pointer to a nested format, any format descriptors within that format are taken from the next argument(s), rather than taking the next argument as an address to an argument list. This means that it can be used as follows: #include foo( c ) char c; { printf("C is '%r'\n", isprint(c) ? "%c" : "\\%03o", c ); } which would print the argument c as an octal character constant if it was not printable, and as a normal character constant if it were printable. This allows complicated formats to be built on the fly, which otherwise might mean 3 or 4 printf statements and a if thrown in for good measure.