HP-UX Reference (11i v1 00/12) - 3 Library Functions N-Z (vol 7)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/nan.3m
________________________________________________________________
___ ___
p
putc(3S) putc(3S)
NAME
putc(), putchar(), fputc(), putw() - put character or word on a stream
SYNOPSIS
#include <stdio.h>
int putc(int c, FILE *stream);
int putchar(int c);
int fputc(int c, FILE *stream);
int putw(int w, FILE *stream);
int putc_unlocked(int c, FILE *stream);
int putchar_unlocked(int c);
Obsolescent Interfaces
int putw_unlocked(int w, FILE *stream);
DESCRIPTION
putc() Writes the character c onto the output stream at the position where the file pointer, if
defined, is pointing.
putchar(c) is defined as putc(c, stdout).
putc() and
putchar() are defined both as macros and as functions.
fputc() Same as putc(), but is a function rather than a macro, and can therefore be used as an
argument. fputc() runs more slowly than putc(), but takes less space per invocation,
and its name can be passed as an argument to a function.
putw() Writes the word (i.e., int in C) w to the output stream (at the position at which the file
pointer, if defined, is pointing). The size of a word is the size of an integer and varies from
machine to machine.
putw() neither assumes nor causes special alignment in the file.
Output streams, with the exception of the standard error stream stderr, are by default buffered if the
output refers to a file and line-buffered if the output refers to a terminal. The standard error output
stream, stderr, is by default unbuffered, but use of freopen() (see fopen(3S)) causes it to become
buffered or line-buffered.
setbuf() or setvbuf() (see setbuf(3S)) can be used to change the stream’s
buffering strategy. putc_unlocked()
, putchar_unlocked(), put character on a stream.
Obsolescent Interfaces
putw_unlocked() put character or word on a stream.
APPLICATION USAGE
putc(), fputc(), putchar() and putw() are thread-safe. These interfaces are not async-cancel-
safe. A cancellation point may occur when a thread is executing one of these interfaces.
After putc(), fputc(), putchar(),orputw() is applied to a stream, the stream becomes byte-
oriented (see orientation(5)).
RETURN VALUE
On success, putc(), putc_unlocked()
, fputc(), putchar() and putchar_unlocked()
each return the value they have written. On failure, they return the constant EOF,
set the error indicator
for the stream, and set
errno to indicate the error.
On success, putw() and putw_unlocked()
return 0. Otherwise, a non-zero value is returned, the
error indicator for the stream is set, and
errno is set to indicate the error.
ERRORS
putc(), putc_unlocked(), putchar(), putchar_unlocked()
, fputc(), putw(), and
putw_unlocked() fail if, either the stream is unbuffered or stream’s buffer needed to be flushed caus-
ing an underlying write() call to be invoked, and:
[EAGAIN] The O_NONBLOCK flag is set for the file descriptor underlying stream and the process
would be delayed in the write operation.
[EBADF] The file descriptor underlying stream is not a valid file descriptor open for writing.
HP-UX Release 11i: December 2000 1 Section 3729
___
___