]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/puts.3
34e3a61086c88295712166d5626c56917d8c17f2
[thirdparty/man-pages.git] / man3 / puts.3
1 '\" t
2 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" Modified Sat Jul 24 18:42:59 1993 by Rik Faith (faith@cs.unc.edu)
7 .TH puts 3 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 fputc, fputs, putc, putchar, puts \- output of characters and strings
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ", " \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <stdio.h>
16 .PP
17 .BI "int fputc(int " c ", FILE *" stream );
18 .BI "int putc(int " c ", FILE *" stream );
19 .BI "int putchar(int " c );
20 .PP
21 .BI "int fputs(const char *restrict " s ", FILE *restrict " stream );
22 .BI "int puts(const char *" s );
23 .fi
24 .SH DESCRIPTION
25 .BR fputc ()
26 writes the character
27 .IR c ,
28 cast to an
29 .IR "unsigned char" ,
30 to
31 .IR stream .
32 .PP
33 .BR putc ()
34 is equivalent to
35 .BR fputc ()
36 except that it may be implemented as a macro which evaluates
37 .I stream
38 more than once.
39 .PP
40 .BI "putchar(" c )
41 is equivalent to
42 .BI "putc(" c ", " stdout ) \fR.
43 .PP
44 .BR fputs ()
45 writes the string
46 .I s
47 to
48 .IR stream ,
49 without its terminating null byte (\[aq]\e0\[aq]).
50 .PP
51 .BR puts ()
52 writes the string
53 .I s
54 and a trailing newline
55 to
56 .IR stdout .
57 .PP
58 Calls to the functions described here can be mixed with each other and with
59 calls to other output functions from the
60 .I stdio
61 library for the same output stream.
62 .PP
63 For nonlocking counterparts, see
64 .BR unlocked_stdio (3).
65 .SH RETURN VALUE
66 .BR fputc (),
67 .BR putc (),
68 and
69 .BR putchar ()
70 return the character written as an
71 .I unsigned char
72 cast to an
73 .I int
74 or
75 .B EOF
76 on error.
77 .PP
78 .BR puts ()
79 and
80 .BR fputs ()
81 return a nonnegative number on success, or
82 .B EOF
83 on error.
84 .SH ATTRIBUTES
85 For an explanation of the terms used in this section, see
86 .BR attributes (7).
87 .ad l
88 .nh
89 .TS
90 allbox;
91 lbx lb lb
92 l l l.
93 Interface Attribute Value
94 T{
95 .BR fputc (),
96 .BR fputs (),
97 .BR putc (),
98 .BR putchar (),
99 .BR puts ()
100 T} Thread safety MT-Safe
101 .TE
102 .hy
103 .ad
104 .sp 1
105 .SH STANDARDS
106 C11, POSIX.1-2008.
107 .SH HISTORY
108 POSIX.1-2001, C89, C99.
109 .SH BUGS
110 It is not advisable to mix calls to output functions from the
111 .I stdio
112 library with low-level calls to
113 .BR write (2)
114 for the file descriptor associated with the same output stream; the results
115 will be undefined and very probably not what you want.
116 .SH SEE ALSO
117 .BR write (2),
118 .BR ferror (3),
119 .BR fgets (3),
120 .BR fopen (3),
121 .BR fputwc (3),
122 .BR fputws (3),
123 .BR fseek (3),
124 .BR fwrite (3),
125 .BR putwchar (3),
126 .BR scanf (3),
127 .BR unlocked_stdio (3)