Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Writing 10

Reply
Thread Tools

Writing 10

 
 
Jerry Coffin
Guest
Posts: n/a
 
      09-14-2004
Phillip Mills <(E-Mail Removed)> wrote in message news:<41461d82_2@127.0.0.1>...

[ ... ]

> > That's simply not true -- Windows does nothing of the sort.

>
> Actually it is *simply* true -- in other words, true for practical
> purposes. It only becomes questionable when you complicate it with
> unnecessary pedantry.


No -- not true for practical, or any other, purposes. You might be
able to argue that it was true for practical purposes if it was
required that every possible implementation of C++ for Windows acted
the same way -- but that's not the case, and in fact there are C++
compilers available for Windows that do NOT do such a translation. As
such, it's an important distinction because if the OP used a different
compiler on Windows, he'd find different behavior. If he believe that
it was Windows itself that caused the behavior in the first place,
this would lead to still greater confusion.

> > The translation is done by the C runtime library,

>
> You're just specifying which part of the Windows system is being
> annoying, not actually contradicting anything.


Perhaps that's the case on your planet, but it certainly isn't true
here on planet earth.

> > and it happens
> > because you've _asked_ it to,

>
> No, it happens without being "asked" anything of the sort. It
> __defaults__ to writing more bytes than it was told to and more bytes
> than it does on other systems under the same conditions. If the OP had
> been required to ask for that behavior, he would probably not have
> joined the legions who have stumbled on it over the years.


Quite the contrary -- the C standard specifies that translated mode is
the default, yes. That means that when you don't specify ios::binary,
you're _asking_ it to do whatever translation is needed to conform to
the local "customs" for a text file.

The fact that you've asked for this behavior tacitly doesn't change
the fact that you have asked for it. If the OP intends to learn to
program in C++, he needs to learn what parameters mean what when
calling standard library functions. Trying to teach him nonsense and
then claiming that it's true for practical purposes is NOT doing him
any favor.

> > not because it "thinks it's smarter than
> > you are". I'd also note that Windows is hardly alone in defining text
> > mode such that translated mode really involves doing a translation.

>
> Right.... DOS, too.


This makes you sound narrow-minded and ignorant. In addition to the
DOS, OS/2, Windows family, MacOS, VMS, z/OS, etc. require translation
of text files. On MacOS the translation is different from on Windows,
but about equally trivial. On VMS, z/OS, and a whole host of older IBM
mainframe OSes, the translations involved are decidedly less trivial,
to put it mildly.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
 
 
 
Richard Herring
Guest
Posts: n/a
 
      09-14-2004
In message <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) writes
>(E-Mail Removed) (Colm) wrote in message
>news:<(E-Mail Removed) .com>...
>[snip]
>> converts it to 10 (I've checked this in debug), but when writes it,
>> where I was expecting to see...
>> 0A 00
>> ...there is actually 3 bytes...
>> 0D 0A 00

>
>This is not a C++ issue, but a Windows issue. You need to turn
>off the thing where a bare linefeed is automatically supplied
>with a carriage return.


That *is* a C++ issue, performed by the C++ runtime library before the
data gets anywhere near Windows, and turned off by passing
std::ios_base::binary as part of the second argument to
basic_fstream:pen(). See other postings in this thread.

--
Richard Herring
 
Reply With Quote
 
 
 
 
Colm
Guest
Posts: n/a
 
      09-16-2004
Thanks for your help lads I'll try that...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a program to create a wireless connection. =?Utf-8?B?bWJvd3llckBwdXJkdWUuZWR1?= Wireless Networking 1 10-05-2005 12:59 PM
writing email problems? Bri Firefox 1 05-12-2005 03:03 AM
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
Unhandled exception in FileStream when writing to a full disk - bug in framework? Amit ASP .Net 8 08-04-2003 03:34 PM
A failure occurred writing to the resources file. Access is denied. -- RESX file is locked? -- WHY? Mark Kamoski ASP .Net 1 07-04-2003 12:02 PM



Advertisments