xref: /original-bsd/lib/libc/stdio/putc.3 (revision a1c2194a)
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
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.\"
8.\" %sccs.include.redist.man%
9.\"
10.\"     @(#)putc.3	6.7 (Berkeley) 06/29/91
11.\"
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
35writes the character
36.Fa c
37(converted to an ``unsigned char'')
38to the output stream pointed to by
39.Fa stream .
40.Pp
41.Fn Putc
42acts essentially identically to
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
51is identical to
52.Fn putc
53with an output stream of
54.Em stdout .
55.Pp
56The
57.Fn putw
58function
59writes the specified
60.Em int
61to the named output
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
76returns 0 on success;
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
99The size and byte order of an
100.Em int
101varies from one machine to another, and
102.Fn putw
103is not recommended for portable applications.
104