DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

putwc(S-osr5)


putwc, putwchar, fputwc -- put wide character on a stream

Syntax

cc . . . -lc

#include <stdio.h>
#include <wchar.h>

wint_t putwc(wint_t wc, FILE *stream);

wint_t putwchar(wint_t wc);

wint_t fputwc(wint_t wc, FILE *stream);

Description

fputwc(S-osr5) converts the wide character wc to its corresponding character and writes the character to the output stream, stream. The character is written to the current file position (indicated by the file-position indicator) if the file associated with the stream supports positioning. The character is appended to the output stream if the file positioning is not supported by the file or if the stream was opened with append mode. The file-position indicator is advanced appropriately when the character is written.

If an error occurs during the writing, the shift state of the output file is undefined.

If fputwc( ) returns successfully and a file is associated to stream, the st_ctime and st_mtime fields of the file are marked for update and will be updated when fflush(S-osr5) or fclose(S-osr5) is called the next time on stream successfully or when exit(S-osr5) or abort(S-osr5) is called.

The call to putwc(S-osr5) is equivalent to a call to fputwc( ), except that putwc( ) may be implemented as a macro and may evaluate stream more than once. Use fputwc( ) if the stream argument has side effects as in fputwc(wc, *fp++), or if the function name needs to be passed as an argument to another function.

The call putwchar(wc) is equivalent to the call putwc(wc, stdout).

Return values

Upon successful completion, putwc( ), putwchar( ), and fputwc( ) return wc. Otherwise, WEOF is returned, an error indicator for the stream is set and errno is set to indicate the error.

Diagnostics

These routines will fail if either the stream is unbuffered or data in the stream's buffer needs to be written, and:


[EAGAIN]
Cannot write to the output stream immediately without blocking the process, and the O_NONBLOCK flag is set for the file descriptor associated with stream.

[EBADF]
Not a valid file descriptor open for writing.

[EFBIG]
Maximum file size or the file size limit for the process is exceeded in the attempt to write to a file.

[EILSEQ]
The wide-character code wc is not a valid character.

[EINTR]
The write operation was terminated by a signal before any data was written.

[EIO]
Cannot write to the controlling terminal. This will happen when the process is in an orphaned background process group and the attempt by the process to write to its controlling terminal fails, because the TOSTOP bit is set to disable the writing and the SIGTTOU signal is not ignored or not blocked by the process.

[ENOMEM]
Insufficient storage space is available.

[ENOSPC]
No free space left on the device where the file associated with stream is stored.

[EPIPE]
The pipe or FIFO being written to is not opened by any process for reading. This error will also send a SIGPIPE signal to the process.

[ENXIO]
Attempt to write to a non-existent device, or to a device whose capabilities are exceeded.

See also

ferror(S-osr5), fflush(S-osr5), fopen(S-osr5), fstat(S-osr5), setbuf(S-osr5), ulimit(S-osr5)

Standards conformance

putwc(S-osr5), putwchar(S-osr5), and fputwc(S-osr5) are conformant with:
X/Open CAE Specification, System Interfaces and Headers, Issue 4, 1992.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005