Commit | Line | Data |
---|---|---|
411867e7 KB |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
d71fbdb0 | 3 | .\" |
411867e7 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" Chris Torek. | |
6 | .\" | |
7 | .\" %sccs.include.redist.man% | |
8 | .\" | |
9 | .\" @(#)putc.3 6.4 (Berkeley) %G% | |
10 | .\" | |
11 | .TH PUTC 3 "" | |
12 | .UC 7 | |
d71fbdb0 | 13 | .SH NAME |
411867e7 | 14 | fputc, putc, putchar, putw \- put a character or word to a stream |
d71fbdb0 | 15 | .SH SYNOPSIS |
411867e7 KB |
16 | .nf |
17 | .ft B | |
18 | #include <stdio.h> | |
19 | ||
20 | int | |
21 | fputc(int c, FILE *stream); | |
22 | ||
23 | int | |
24 | putc(int c, FILE *stream); | |
25 | ||
26 | int | |
27 | putchar(int c); | |
28 | ||
29 | int | |
30 | putw(int w, FILE *stream); | |
31 | .ft R | |
32 | .fi | |
d71fbdb0 | 33 | .SH DESCRIPTION |
411867e7 KB |
34 | .I Fputc |
35 | writes the character | |
d71fbdb0 | 36 | .I c |
411867e7 KB |
37 | (converted to an ``unsigned char'') |
38 | to the specified output | |
d71fbdb0 | 39 | .IR stream . |
d71fbdb0 | 40 | .PP |
411867e7 KB |
41 | .I Putc |
42 | acts essentially identically to | |
43 | .IR fputc , | |
44 | but is a macro that expands in-line. | |
d71fbdb0 | 45 | .PP |
411867e7 KB |
46 | .I Putchar |
47 | is identical to | |
48 | .I putc | |
49 | with an output stream of | |
50 | .BR stdout . | |
d71fbdb0 KM |
51 | .PP |
52 | .I Putw | |
411867e7 KB |
53 | writes the specified |
54 | .B int | |
55 | to the named output | |
d71fbdb0 | 56 | .IR stream . |
411867e7 KB |
57 | .SH "RETURN VALUE" |
58 | These functions return the integer constant | |
d71fbdb0 KM |
59 | .SM |
60 | .B EOF | |
411867e7 KB |
61 | upon write error, |
62 | or if an attempt is made to write a read-only stream. | |
63 | .I Putw | |
64 | returns 0 on success; | |
65 | the other functions return the character printed. | |
66 | .SH "SEE ALSO" | |
67 | ferror(3), fopen(3), getc(3), stdio(3) | |
d71fbdb0 | 68 | .SH BUGS |
411867e7 KB |
69 | The size and byte order of an |
70 | .B int | |
71 | varies from one machine to another, and | |
72 | .I putw | |
73 | is not recommended for portable applications. | |
74 | .PP | |
d71fbdb0 KM |
75 | Because it is implemented as a macro, |
76 | .I putc | |
77 | treats a | |
78 | .I stream | |
411867e7 KB |
79 | argument with side effects incorrectly. |
80 | In particular, ``putc(c, *f++);'' may not work sensibly | |
81 | (although ``putc(*cp++, f);'' | |
82 | .I does | |
83 | work correctly). |