Commit | Line | Data |
---|---|---|
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 | |
32 | The | |
33 | .Fn fputc | |
34 | function | |
411867e7 | 35 | writes the character |
ae59e04c | 36 | .Fa c |
411867e7 | 37 | (converted to an ``unsigned char'') |
ae59e04c CL |
38 | to the output stream pointed to by |
39 | .Fa stream . | |
40 | .Pp | |
41 | .Fn Putc | |
411867e7 | 42 | acts essentially identically to |
ae59e04c CL |
43 | .Fn fputc , |
44 | but is a macro that expands in-line. It may evaluate | |
45 | .Fa stream | |
46 | more than once, so arguments given to | |
47 | .Fn putc | |
48 | should not be expressions with potential side effects. | |
49 | .Pp | |
50 | .Fn Putchar | |
411867e7 | 51 | is identical to |
ae59e04c | 52 | .Fn putc |
411867e7 | 53 | with an output stream of |
ae59e04c CL |
54 | .Em stdout . |
55 | .Pp | |
56 | The | |
57 | .Fn putw | |
58 | function | |
411867e7 | 59 | writes the specified |
ae59e04c | 60 | .Em int |
411867e7 | 61 | to the named output |
ae59e04c CL |
62 | .Fa stream . |
63 | .Sh RETURN VALUES | |
64 | The functions, | |
65 | .Fn fputc , | |
66 | .Fn putc | |
67 | and | |
68 | .Fn putchar | |
69 | return the character written. | |
70 | If an error occurs, the value | |
71 | .Dv EOF | |
72 | is returned. | |
73 | The | |
74 | .Fn putw | |
75 | function | |
411867e7 | 76 | returns 0 on success; |
ae59e04c CL |
77 | .Dv EOF |
78 | is returned if | |
79 | a write error occurs, | |
80 | or 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 | |
87 | The functions | |
88 | .Fn fputc , | |
89 | .Fn putc , | |
90 | and | |
91 | .Fn putchar , | |
92 | conform to | |
93 | .St -ansiC . | |
94 | A function | |
95 | .Fn putw | |
96 | function appeared in | |
97 | .At v6 . | |
98 | .Sh BUGS | |
411867e7 | 99 | The size and byte order of an |
ae59e04c | 100 | .Em int |
411867e7 | 101 | varies from one machine to another, and |
ae59e04c | 102 | .Fn putw |
411867e7 | 103 | is not recommended for portable applications. |