Path: csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: iso646.h Date: Fri, 26 Jan 2024 15:41:43 -0800 Organization: None to speak of Lines: 40 Message-ID: <871qa33bns.fsf@nosuchdomain.example.com> References: <87frym7l3p.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="882dfc4555872a9a03fa1fa7029d3d2d"; logging-data="3228929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EicU7Xu9gUS5UTucthMkJ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:VWeueO6U2P1AZyAa4AGDTp8JnGA= sha1:9GKcglgpLZLLU7QhnRhkxFGcDDE= Xref: csiph.com comp.lang.c:381021 Lawrence D'Oliveiro writes: > On Fri, 26 Jan 2024 22:46:25 +0100, Janis Papanagnou wrote: >> On 26.01.2024 22:16, Lawrence D'Oliveiro wrote: >>> On Thu, 25 Jan 2024 14:07:25 +0100, David Brown wrote: >>> >>>> "cout << one() << two() << three();" >>> >>> Those C++ operators for I/O are a brain-dead idea. C-style printf >>> formats actually work better. >> >> Well, no. There's a reason for using operators. > > But remember, you often need to do localized output. Which means parts of > a message may need to be reordered for grammatical purposes. > > You can do this with printf, but not with C++ output operators. You can do this with POSIX printf. POSIX specifies an extension to printf that allows arguments to be re-ordered. For example: printf("%2$s%1$s\n", "foo", "bar"); prints "barfoo". ISO C does not have this feature. Another way to reorder arguments is to construct a string and then print it. (String manipulation can be easier in C++ than in C, but that's a side issue.) C++'s `cout << ...` has advantages and disadvantages. It's much more type-safe than printf, something that's possible only because of C++'s operator overloading. I can print something without first looking up its type and then determining what format string I need to specify that type. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */