xref: /freebsd/lib/libc/stdio/fputs.3 (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  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.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd January 23, 2020
33.Dt FPUTS 3
34.Os
35.Sh NAME
36.Nm fputs ,
37.Nm fputs_unlocked ,
38.Nm puts
39.Nd output a line to a stream
40.Sh LIBRARY
41.Lb libc
42.Sh SYNOPSIS
43.In stdio.h
44.Ft int
45.Fn fputs "const char *str" "FILE *stream"
46.Ft int
47.Fn fputs_unlocked "const char *str" "FILE *stream"
48.Ft int
49.Fn puts "const char *str"
50.Sh DESCRIPTION
51The function
52.Fn fputs
53writes the string pointed to by
54.Fa str
55to the stream pointed to by
56.Fa stream .
57.\" The terminating
58.\" .Dv NUL
59.\" character is not written.
60.Pp
61The
62.Fn fputs_unlocked
63function is equivalent to
64.Fn fputs ,
65except that the caller is responsible for locking the stream with
66.Xr flockfile 3
67before calling it.
68This function may be used to avoid the overhead of locking the stream and to
69prevent races when multiple threads are operating on the same stream.
70.Pp
71The function
72.Fn puts
73writes the string
74.Fa str ,
75and a terminating newline character,
76to the stream
77.Dv stdout .
78.Sh RETURN VALUES
79The functions
80.Fn fputs
81and
82.Fn puts
83return a nonnegative integer on success and
84.Dv EOF
85on error.
86.Sh ERRORS
87.Bl -tag -width Er
88.It Bq Er EBADF
89The
90.Fa stream
91argument
92is not a writable stream.
93.El
94.Pp
95The functions
96.Fn fputs
97and
98.Fn puts
99may also fail and set
100.Va errno
101for any of the errors specified for the routines
102.Xr write 2 .
103.Sh SEE ALSO
104.Xr ferror 3 ,
105.Xr fputws 3 ,
106.Xr putc 3 ,
107.Xr stdio 3
108.Sh STANDARDS
109The functions
110.Fn fputs
111and
112.Fn puts
113conform to
114.St -isoC .
115