| 1 | .\" @(#)putc.3 6.2 (Berkeley) %G% |
| 2 | .\" |
| 3 | .TH PUTC 3S "" |
| 4 | .AT 3 |
| 5 | .SH NAME |
| 6 | putc, putchar, fputc, putw \- put character or word on a stream |
| 7 | .SH SYNOPSIS |
| 8 | .B #include <stdio.h> |
| 9 | .PP |
| 10 | .B int putc(c, stream) |
| 11 | .br |
| 12 | .B char c; |
| 13 | .br |
| 14 | .SM |
| 15 | .B FILE |
| 16 | .B *stream; |
| 17 | .PP |
| 18 | .B int putchar(c) |
| 19 | .PP |
| 20 | .B int fputc(c, stream) |
| 21 | .br |
| 22 | .SM |
| 23 | .B FILE |
| 24 | .B *stream; |
| 25 | .PP |
| 26 | .B int putw(w, stream) |
| 27 | .br |
| 28 | .SM |
| 29 | .B FILE |
| 30 | .B *stream; |
| 31 | .SH DESCRIPTION |
| 32 | .I Putc |
| 33 | appends the character |
| 34 | .I c |
| 35 | to the named output |
| 36 | .IR stream . |
| 37 | It returns the character written. |
| 38 | .PP |
| 39 | .IR Putchar ( c ) |
| 40 | is defined as |
| 41 | .IR putc ( c , |
| 42 | .BR stdout ). |
| 43 | .PP |
| 44 | .I Fputc |
| 45 | behaves like |
| 46 | .IR putc , |
| 47 | but is a genuine function rather than a macro. |
| 48 | .PP |
| 49 | .I Putw |
| 50 | appends word (that is, |
| 51 | .BR int ) |
| 52 | .I w |
| 53 | to the output |
| 54 | .IR stream . |
| 55 | It returns the word written. |
| 56 | .I Putw |
| 57 | neither assumes nor causes special alignment in the file. |
| 58 | .SH "SEE ALSO" |
| 59 | fopen(3S), |
| 60 | fclose(3S), |
| 61 | getc(3S), |
| 62 | puts(3S), |
| 63 | printf(3S), |
| 64 | fread(3S) |
| 65 | .SH DIAGNOSTICS |
| 66 | These functions return the constant |
| 67 | .SM |
| 68 | .B EOF |
| 69 | upon error. Since this is a good integer, |
| 70 | .IR ferror (3S) |
| 71 | should be used to detect |
| 72 | .I putw |
| 73 | errors. |
| 74 | .SH BUGS |
| 75 | Because it is implemented as a macro, |
| 76 | .I putc |
| 77 | treats a |
| 78 | .I stream |
| 79 | argument with side effects improperly. In particular |
| 80 | .IP "putc(c, *f++);" |
| 81 | .PP |
| 82 | doesn't work sensibly. |
| 83 | .PP |
| 84 | Errors can occur long after the call to |
| 85 | .IR putc . |