Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: sprintf and the trailing null Date: Fri, 10 Jul 2015 08:33:18 -0700 Organization: None to speak of Lines: 26 Message-ID: References: <4218c1d7-073c-48a4-8485-687a794848d1@googlegroups.com> <8ee8235d-f52a-4e2c-94b5-11d7b86cbc60@googlegroups.com> <87a8v9uwi8.fsf@bsb.me.uk> <87k2ucucrk.fsf@bsb.me.uk> <87zj36d19c.fsf@bazspaz.fatphil.org> <87wpy8b8uj.fsf@bazspaz.fatphil.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UdnZELhTfMmR5MWXDmhUu" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:NIYeJoFsjTsXhDFAQ7rUbTHQ/X0= sha1:NeM4A2YCEDxE5rr5RAxSmF641z4= Xref: csiph.com comp.lang.c:65119 Bartc writes: > On 10/07/2015 11:33, Phil Carmody wrote: >> Bartc writes: > >>> But a % at the of a string should be an error. >> >> Says who? If you, on what authority? If the C standard, chapter >> and verse, please? > > 7.20.6.1p9 says the behaviour is undefined. Yes -- but it's 7.21.6.1p6 in C11. > But whatever that says, under the current rules, a sole "%" at the end > of format string produces no output and serves no purpose. What's your basis for saying it produces no output? The behavior is undefined; it could print a '%' character, or the word "PERCENT", or it could, in principle, do anything. (It happens to print nothing in the implementation I'm using.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"