]> git.saurik.com Git - apple/libc.git/blame - stdio/FreeBSD/putc.3
Libc-1353.11.2.tar.gz
[apple/libc.git] / stdio / FreeBSD / putc.3
CommitLineData
5b2abdfb 1.\" Copyright (c) 1990, 1991, 1993
e9ce8d39
A
2.\" The Regents of the University of California. All rights reserved.
3.\"
5b2abdfb
A
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
e9ce8d39
A
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
e9ce8d39
A
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
5b2abdfb 32.\" @(#)putc.3 8.1 (Berkeley) 6/4/93
1f2f436a 33.\" $FreeBSD: src/lib/libc/stdio/putc.3,v 1.16 2007/01/09 00:28:07 imp Exp $
e9ce8d39 34.\"
9385eb3d 35.Dd January 10, 2003
5b2abdfb 36.Dt PUTC 3
e9ce8d39
A
37.Os
38.Sh NAME
5b2abdfb
A
39.Nm fputc ,
40.Nm putc ,
9385eb3d 41.Nm putc_unlocked ,
5b2abdfb 42.Nm putchar ,
9385eb3d 43.Nm putchar_unlocked ,
5b2abdfb
A
44.Nm putw
45.Nd output a character or word to a stream
e9ce8d39
A
46.Sh LIBRARY
47.Lb libc
48.Sh SYNOPSIS
5b2abdfb
A
49.In stdio.h
50.Ft int
ad3c9f2a
A
51.Fo fputc
52.Fa "int c"
53.Fa "FILE *stream"
54.Fc
5b2abdfb 55.Ft int
ad3c9f2a
A
56.Fo putc
57.Fa "int c"
58.Fa "FILE *stream"
59.Fc
e9ce8d39 60.Ft int
ad3c9f2a
A
61.Fo putc_unlocked
62.Fa "int c"
63.Fa "FILE *stream"
64.Fc
9385eb3d 65.Ft int
ad3c9f2a
A
66.Fo putchar
67.Fa "int c"
68.Fc
5b2abdfb 69.Ft int
ad3c9f2a
A
70.Fo putchar_unlocked
71.Fa "int c"
72.Fc
9385eb3d 73.Ft int
ad3c9f2a
A
74.Fo putw
75.Fa "int w"
76.Fa "FILE *stream"
77.Fc
e9ce8d39
A
78.Sh DESCRIPTION
79The
5b2abdfb
A
80.Fn fputc
81function
82writes the character
83.Fa c
84(converted to an ``unsigned char'')
85to the output stream pointed to by
86.Fa stream .
87.Pp
88The
89.Fn putc
3d9156a7
A
90macro acts essentially identically to
91.Fn fputc ,
92but is a macro that expands in-line.
93It may evaluate
94.Fa stream
95more than once, so arguments given to
96.Fn putc
97should not be expressions with potential side effects.
5b2abdfb 98.Pp
e9ce8d39 99The
5b2abdfb 100.Fn putchar
9385eb3d 101function
5b2abdfb
A
102is identical to
103.Fn putc
104with an output stream of
9385eb3d 105.Dv stdout .
5b2abdfb
A
106.Pp
107The
108.Fn putw
109function
110writes the specified
9385eb3d 111.Vt int
5b2abdfb
A
112to the named output
113.Fa stream .
9385eb3d
A
114.Pp
115The
116.Fn putc_unlocked
117and
118.Fn putchar_unlocked
119functions are equivalent to
120.Fn putc
121and
122.Fn putchar
123respectively,
124except that the caller is responsible for locking the stream
125with
126.Xr flockfile 3
127before calling them.
128These functions may be used to avoid the overhead of locking the stream
129for each character, and to avoid output being interspersed from multiple
130threads writing to the same stream.
e9ce8d39 131.Sh RETURN VALUES
5b2abdfb
A
132The functions,
133.Fn fputc ,
9385eb3d
A
134.Fn putc ,
135.Fn putchar ,
ad3c9f2a 136.Fn putc_unlocked ,
5b2abdfb 137and
9385eb3d 138.Fn putchar_unlocked
5b2abdfb
A
139return the character written.
140If an error occurs, the value
141.Dv EOF
142is returned.
e9ce8d39 143The
5b2abdfb
A
144.Fn putw
145function
146returns 0 on success;
147.Dv EOF
148is returned if
149a write error occurs,
150or if an attempt is made to write a read-only stream.
151.Sh SEE ALSO
152.Xr ferror 3 ,
9385eb3d 153.Xr flockfile 3 ,
5b2abdfb
A
154.Xr fopen 3 ,
155.Xr getc 3 ,
9385eb3d 156.Xr putwc 3 ,
5b2abdfb
A
157.Xr stdio 3
158.Sh STANDARDS
159The functions
160.Fn fputc ,
161.Fn putc ,
162and
163.Fn putchar ,
164conform to
165.St -isoC .
9385eb3d
A
166The
167.Fn putc_unlocked
168and
169.Fn putchar_unlocked
170functions conform to
171.St -p1003.1-2001 .
5b2abdfb
A
172A function
173.Fn putw
174function appeared in
175.At v6 .
176.Sh BUGS
177The size and byte order of an
9385eb3d 178.Vt int
5b2abdfb
A
179varies from one machine to another, and
180.Fn putw
181is not recommended for portable applications.