add ANSI contribution notice
[unix-history] / usr / src / lib / libc / stdio / putc.3
CommitLineData
ae59e04c 1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
411867e7 2.\" All rights reserved.
d71fbdb0 3.\"
411867e7 4.\" This code is derived from software contributed to Berkeley by
043368e6
KB
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
411867e7
KB
8.\" %sccs.include.redist.man%
9.\"
043368e6 10.\" @(#)putc.3 6.7 (Berkeley) %G%
411867e7 11.\"
ae59e04c
CL
12.Dd
13.Dt PUTC 3
14.Os
15.Sh NAME
16.Nm fputc ,
17.Nm putc ,
18.Nm putchar ,
19.Nm putw
20.Nd output a character or word to a stream
21.Sh SYNOPSIS
22.Fd #include <stdio.h>
23.Ft int
24.Fn fputc "int c" "FILE *stream"
25.Ft int
26.Fn putc "int c" "FILE *stream"
27.Ft int
28.Fn putchar "int c"
29.Ft int
30.Fn putw "int w" "FILE *stream"
31.Sh DESCRIPTION
32The
33.Fn fputc
34function
411867e7 35writes the character
ae59e04c 36.Fa c
411867e7 37(converted to an ``unsigned char'')
ae59e04c
CL
38to the output stream pointed to by
39.Fa stream .
40.Pp
41.Fn Putc
411867e7 42acts essentially identically to
ae59e04c
CL
43.Fn fputc ,
44but is a macro that expands in-line. It may evaluate
45.Fa stream
46more than once, so arguments given to
47.Fn putc
48should not be expressions with potential side effects.
49.Pp
50.Fn Putchar
411867e7 51is identical to
ae59e04c 52.Fn putc
411867e7 53with an output stream of
ae59e04c
CL
54.Em stdout .
55.Pp
56The
57.Fn putw
58function
411867e7 59writes the specified
ae59e04c 60.Em int
411867e7 61to the named output
ae59e04c
CL
62.Fa stream .
63.Sh RETURN VALUES
64The functions,
65.Fn fputc ,
66.Fn putc
67and
68.Fn putchar
69return the character written.
70If an error occurs, the value
71.Dv EOF
72is returned.
73The
74.Fn putw
75function
411867e7 76returns 0 on success;
ae59e04c
CL
77.Dv EOF
78is returned if
79a write error occurs,
80or if an attempt is made to write a read-only stream.
81.Sh SEE ALSO
82.Xr ferror 3 ,
83.Xr fopen 3 ,
84.Xr getc 3 ,
85.Xr stdio 3
86.Sh STANDARDS
87The functions
88.Fn fputc ,
89.Fn putc ,
90and
91.Fn putchar ,
92conform to
93.St -ansiC .
94A function
95.Fn putw
96function appeared in
97.At v6 .
98.Sh BUGS
411867e7 99The size and byte order of an
ae59e04c 100.Em int
411867e7 101varies from one machine to another, and
ae59e04c 102.Fn putw
411867e7 103is not recommended for portable applications.