1.\" $OpenBSD: putc.3,v 1.7 2003/06/02 20:18:37 millert 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. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.Dd June 4, 1993 35.Dt PUTC 3 36.Os 37.Sh NAME 38.Nm fputc , 39.Nm putc , 40.Nm putchar , 41.Nm putw 42.Nd output a character or word to a stream 43.Sh SYNOPSIS 44.Fd #include <stdio.h> 45.Ft int 46.Fn fputc "int c" "FILE *stream" 47.Ft int 48.Fn putc "int c" "FILE *stream" 49.Ft int 50.Fn putchar "int c" 51.Ft int 52.Fn putw "int w" "FILE *stream" 53.Sh DESCRIPTION 54The 55.Fn fputc 56function writes the character 57.Fa c 58(converted to an 59.Li unsigned char ) 60to the output stream pointed to by 61.Fa stream . 62.Pp 63.Fn putc 64acts essentially identically to 65.Fn fputc , 66but is a macro that expands in-line. 67It may evaluate 68.Fa stream 69more than once, so arguments given to 70.Fn putc 71should not be expressions with potential side effects. 72.Pp 73.Fn putchar 74is identical to 75.Fn putc 76with an output stream of 77.Em stdout . 78.Pp 79The 80.Fn putw 81function writes the specified 82.Li int 83.Fa w 84to the named output 85.Fa stream . 86.Sh RETURN VALUES 87The functions 88.Fn fputc , 89.Fn putc , 90and 91.Fn putchar 92return the character written. 93If an error occurs, the value 94.Dv EOF 95is returned. 96The 97.Fn putw 98function returns 0 on success; 99.Dv EOF 100is returned if a write error occurs, 101or if an attempt is made to write a read-only stream. 102.Sh SEE ALSO 103.Xr ferror 3 , 104.Xr fopen 3 , 105.Xr getc 3 , 106.Xr stdio 3 107.Sh STANDARDS 108The functions 109.Fn fputc , 110.Fn putc , 111and 112.Fn putchar , 113conform to 114.St -ansiC . 115A function 116.Fn putw 117function appeared in 118.At v6 . 119.Sh BUGS 120Since the size and byte order of an 121.Li int 122varies from one machine to another, 123.Fn putw 124is not recommended for portable applications. 125