Re: write
- From: phil-news-nospam@xxxxxxxx
- Date: 29 Apr 2008 19:07:38 GMT
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) |
.
- Prev by Date: Re: setrlimit() extension suggestion
- Next by Date: Re: write
- Previous by thread: Re: write
- Next by thread: Re: write
- Index(es):
Relevant Pages
|