xref: /openbsd/lib/libc/stdio/putc.3 (revision aa86bf2d)
1.\"	$OpenBSD: putc.3,v 1.5 2000/04/20 01:39:32 aaron 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.Dd June 4, 1993
39.Dt PUTC 3
40.Os
41.Sh NAME
42.Nm fputc ,
43.Nm putc ,
44.Nm putchar ,
45.Nm putw
46.Nd output a character or word to a stream
47.Sh SYNOPSIS
48.Fd #include <stdio.h>
49.Ft int
50.Fn fputc "int c" "FILE *stream"
51.Ft int
52.Fn putc "int c" "FILE *stream"
53.Ft int
54.Fn putchar "int c"
55.Ft int
56.Fn putw "int w" "FILE *stream"
57.Sh DESCRIPTION
58The
59.Fn fputc
60function writes the character
61.Fa c
62(converted to an
63.Li unsigned char )
64to the output stream pointed to by
65.Fa stream .
66.Pp
67.Fn putc
68acts essentially identically to
69.Fn fputc ,
70but is a macro that expands in-line.
71It may evaluate
72.Fa stream
73more than once, so arguments given to
74.Fn putc
75should not be expressions with potential side effects.
76.Pp
77.Fn putchar
78is identical to
79.Fn putc
80with an output stream of
81.Em stdout .
82.Pp
83The
84.Fn putw
85function writes the specified
86.Li int
87.Fa w
88to the named output
89.Fa stream .
90.Sh RETURN VALUES
91The functions,
92.Fn fputc ,
93.Fn putc ,
94and
95.Fn putchar
96return the character written.
97If an error occurs, the value
98.Dv EOF
99is returned.
100The
101.Fn putw
102function
103returns 0 on success;
104.Dv EOF
105is returned if a write error occurs,
106or if an attempt is made to write a read-only stream.
107.Sh SEE ALSO
108.Xr ferror 3 ,
109.Xr fopen 3 ,
110.Xr getc 3 ,
111.Xr stdio 3
112.Sh STANDARDS
113The functions
114.Fn fputc ,
115.Fn putc ,
116and
117.Fn putchar ,
118conform to
119.St -ansiC .
120A function
121.Fn putw
122function appeared in
123.At v6 .
124.Sh BUGS
125Since the size and byte order of an
126.Li int
127varies from one machine to another,
128.Fn putw
129is not recommended for portable applications.
130