stdio performance in tango, stdlib, and perl
James Dennett
jdennett at acm.org
Fri Mar 23 08:33:32 PDT 2007
Roberto Mariottini wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Roberto Mariottini wrote:
>>> The portable way to write a newline in C++ is to use the 'endl'
>>> modifier.
>>> Your program is not portable, on Windows it will generate Unix text
>>> files.
>>
>> Wrong. Newline translation will be correct on both systems.
>
> It depends on how you open the file: 'endl' works even with files open
> in binary mode (the default on most platforms, the default on the
> average programmer).
>
> Or else, say that 'endl' is yet another design error in C++.
>
> Ciao
The difference between '\n' and std::endl in C++ is only
that std::endl flushes the stream after writing a newline
(well, and uses widen to convert to the character type of
the stream, but binary mode makes no difference to that,
it's a property of the template parameters of the stream
type to which you are writing).
C++ doesn't default to binary mode, though on many
platforms that's of academic concern only as there is
no distinction between text and binary modes.
And this is somewhat off-topic for d.D, I think, except
in that we'd like D's IO to be better than C++'s.
-- James
More information about the Digitalmars-d
mailing list