C Language and Libraries Help (clang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
_write
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
─────Run-Time Library───────────────────────────────────────────────────────
The _write function writes <count> bytes from <buffer> into the
file associated with <handle>. The write operation begins at the
current position of the file pointer (if any) associated with the
given file. If the file is open for appending, the operation
begins at the current end of the file. After the write operation,
the file pointer is increased by the number of bytes actually
written.
Return Value
The _write function returns the number of bytes actually written.
The return value may be positive but less than <count> (for
example, when _write runs out of disk space before <count> bytes
are written).
A return value of -1 indicates an error. In this case, errno is
set to either EBADF or ENOSPC.
For 16-bit targets, if you are writing more than 32K (the maximum
size for type int) to a file, the return value should be of type
unsigned. However, the maximum number of bytes that can be written
to a file at one time is 65,534, since 65,535 (or 0xFFFF) is
indistinguishable from -1, and would return an error.
If the file is opened in text mode, each linefeed character is
replaced with a carriage-return─linefeed pair in the output. The
replacement does not affect the return value.
When writing to files opened in text mode, the _write function
treats a CTRL+Z character as the logical end-of-file. When writing
to a device, _write treats a CTRL+Z character in the buffer as an
output terminator.
-♦-