logoalt Hacker News

How do I inform Windows that I'm writing a binary file?

18 pointsby ingvelast Tuesday at 6:14 AM18 commentsview on HN

Comments

Isamutoday at 1:07 AM

Going all the way back to the earliest C compilers on DOS. There was a decision made to make “\n” just work on DOS for portability of Unix programs, and to make the examples from the C programming book just work.

But in Unix “\n” is a single byte, and in DOS it is 2. So they introduced text and binary modes for files on DOS. Behind the scenes the library will handle the extra byte. This is not necessary in Unix.

I used to have to be careful about importing files to DOS. Did the file come from Unix?

show 1 reply
saltyoldmanlast Tuesday at 7:12 AM

fopen(..., "wb") ?

lmmtoday at 12:49 AM

The article seems to be taking the position that the C runtime library is not part of "Windows", which feels like a rather odd view to me. What is the stable API that Windows offers to application developers if not that?

show 3 replies