HP-UX Reference (11i v2 04/09) - 3 Library Functions N-Z (vol 7)
p
putc(3S) putc(3S)
[EINTR] A signal was caught during the
write() system call.
[EIO] A physical I/O error has occurred, or the process is in a background process group and is
attempting to write to its controlling terminal,
TOSTOP is set, the process is neither
ignoring nor blocking the
SIGTTOU signal, and the process group of the process is
orphaned.
[ENOSPC] There was no free space remaining on the device containing the file.
[EPIPE] An attempt is made to write to a pipe or FIFO that is not open for reading by any process.
A
SIGPIPE signal is also sent to the process.
Additional
errno values can be set by the underlying
write() function (see write(2)).
WARNINGS
The
putc() and putchar() routines are implemented as both library functions and macros. The
macro versions, which are used by default, are defined in
<stdio.h>. To obtain the library function
either use a
#undef to remove the macro definition or, if compiling in ANSI-C mode, enclose the function
name in parentheses or use the function address. The following example illustrates each of these
methods:
#include <stdio.h>
#undef putc
...
main()
{
int (*put_char()) ();"
...
return_val=putc(c,fd);"
...
return_val=(putc)(c,fd1);"
...
put_char = putchar;"
};
Line buffering may cause confusion or malfunctioning of programs that use standard I/O routines but use
read() themselves to read from standard input. When a large amount of computation is done after
printing part of a line on an output terminal, it is necessary to fflush() (see fclose (3S)) the standard
output before beginning the computation.
The macro version of
putc() incorrectly treats the argument stream with side effects. In particular, the
following call may not work as expected:
putc(c, *f++);
The function version of putc() or fputc() should be used instead.
Because of possible differences in word length and byte ordering, files written using
putw() are
machine-dependent, and may not be readable by getw() on a different processor.
putw_unlocked() is an obsolescent interface supported only for compatibility with existing DCE
applications. New multithreaded applications should use putc(), putchar() and
putw().
Reentrant Interfaces
If
_REENTRANT is defined, the locked versions of the library functions for putc() and putchar() are
used by default.
SEE ALSO
fclose(3S), ferror(3S), flockfile(3S), fopen(3S), getc(3S), fread(3S), printf(3S), puts(3S), setbuf(3S), orienta-
tion(5), thread_safety(5).
STANDARDS CONFORMANCE
putc(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
fputc(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
putchar(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
putw(): AES, SVID2, SVID3, XPG2, XPG3, XPG4
HP-UX 11i Version 2: September 2004 − 2 − Hewlett-Packard Company Section 3−−843