xref: /netbsd-src/lib/libc/stdio/putc.3 (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1.\"	$NetBSD: putc.3,v 1.5 1998/08/29 08:32:34 lukem Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Chris Torek and the American National Standards Committee X3,
8.\" on Information Processing Systems.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\"    must display the following acknowledgement:
20.\"	This product includes software developed by the University of
21.\"	California, Berkeley and its contributors.
22.\" 4. Neither the name of the University nor the names of its contributors
23.\"    may be used to endorse or promote products derived from this software
24.\"    without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36.\" SUCH DAMAGE.
37.\"
38.\"     @(#)putc.3	8.1 (Berkeley) 6/4/93
39.\"
40.Dd June 4, 1993
41.Dt PUTC 3
42.Os
43.Sh NAME
44.Nm fputc ,
45.Nm putc ,
46.Nm putchar ,
47.Nm putw
48.Nd output a character or word to a stream
49.Sh LIBRARY
50.Lb libc
51.Sh SYNOPSIS
52.Fd #include <stdio.h>
53.Ft int
54.Fn fputc "int c" "FILE *stream"
55.Ft int
56.Fn putc "int c" "FILE *stream"
57.Ft int
58.Fn putchar "int c"
59.Ft int
60.Fn putw "int w" "FILE *stream"
61.Sh DESCRIPTION
62The
63.Fn fputc
64function
65writes the character
66.Fa c
67(converted to an ``unsigned char'')
68to the output stream pointed to by
69.Fa stream .
70.Pp
71.Fn putc
72acts essentially identically to
73.Fn fputc ,
74but is a macro that expands in-line. It may evaluate
75.Fa stream
76more than once, so arguments given to
77.Fn putc
78should not be expressions with potential side effects.
79.Pp
80.Fn putchar
81is identical to
82.Fn putc
83with an output stream of
84.Em stdout .
85.Pp
86The
87.Fn putw
88function
89writes the specified
90.Em int
91to the named output
92.Fa stream .
93.Sh RETURN VALUES
94The functions,
95.Fn fputc ,
96.Fn putc
97and
98.Fn putchar
99return the character written.
100If an error occurs, the value
101.Dv EOF
102is returned.
103The
104.Fn putw
105function
106returns 0 on success;
107.Dv EOF
108is returned if
109a write error occurs,
110or if an attempt is made to write a read-only stream.
111.Sh SEE ALSO
112.Xr ferror 3 ,
113.Xr fopen 3 ,
114.Xr getc 3 ,
115.Xr stdio 3
116.Sh STANDARDS
117The functions
118.Fn fputc ,
119.Fn putc ,
120and
121.Fn putchar ,
122conform to
123.St -ansiC .
124A function
125.Fn putw
126function appeared in
127.At v6 .
128.Sh BUGS
129The size and byte order of an
130.Em int
131varies from one machine to another, and
132.Fn putw
133is not recommended for portable applications.
134