Re: write



On Sun, 27 Apr 2008 22:04:48 GMT Bill Cunningham <nospam@xxxxxxxxx> wrote:

| Yes. Great! Exactly what I was looking for. I guess I need to include
| more headers. But where is it descided in the program that the file opened
| written to and eventually closed is going to be a binary or text file?

Some computer systems distinguish between text and binary files. Because of
that, the Standard C Library, intended to be portable over such a very wide
range of computers, accomodates the distinguish by providing an option in the
fopen() library call. However, in the subset of computer systems that are
POSIX compliant, no such distinction is recognized. On genuine UNIX systems,
the distinction does not exist. Some systems, like Windows, have such a
distinction, but that has to be handled by the program itself that chooses
to call the POSIX compatible functions.

To answer your question, the decision between binary and text does not take
place if running on UNIX, or is handled by how the data to be written is
put together (such as using both line feed and carriage return together for
between-line separators) before the write() call. Other programs in a UNIX
environment may interpret the data in a file as text or binary based on what
byte or character values are present in the file.

In C programs using the Standard C Library, you simply work with '\n' as the
line separator. The library handles translating to/from the underlying system
as needed (not needed in a UNIX environment like Linux). If you use the wrong
text vs. binary selection on fopen() in Linux or UNIX, it will still work, but
is still wrong. It won't work right on other systems (if ever ported there).

I hope that's enough info to get you going.

--
|WARNING: Due to extreme spam, I no longer see any articles originating from |
| Google Groups. If you want your postings to be seen by more readers |
| you will need to find a different place to post on Usenet. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.



Relevant Pages

  • Re: Bleeping GNU Linux
    ... Linux is UNIX-like, ... I see your distinction, ... the only reason why Linux is *Formally* called UNIX ... is because it hasn't passed the required compatibility ...
    (comp.unix.solaris)
  • Re: The Problems With Linux
    ... > Here are the problems with Linux: ... programmers of UNIX, Open Source software, and Shareware. ... programs only available from BSD. ... BSD code is used by Microsoft in it's Windows NT/9x/2K/XP code. ...
    (comp.os.linux)
  • RE: [Full-Disclosure] CyberInsecurity: The cost of Monopoly
    ... I've used UNIX, ... I've used/use Linux, ... > inefficient operating system - if most other Windows ... This is why I don't run POS operating systems. ...
    (Full-Disclosure)
  • Re: hmm..
    ... I checked definitely do not have any UNIX history to them. ... (ie I think "real UNIX" has SIGBUS at 10, while Linux didn't originally ... the "ctype" name comes "character type", and the ... the "ctype" interfaces are defined by the C standard library. ...
    (Linux-Kernel)
  • Re: Newbie Experience
    ... I've only been around since FreeBSD 5.4 ... FreeBSD kernel too. ... always sunshine and linux is farts. ... in the hey day of AT&T Unix I'm ...
    (freebsd-questions)