]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/puts.3
man*/: srcfix (Use .P instead of .PP or .LP)
[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 .P
17 .BI "int fputc(int " c ", FILE *" stream );
18 .BI "int putc(int " c ", FILE *" stream );
19 .BI "int putchar(int " c );
20 .P
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 .P
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 .P
40 .BI "putchar(" c )
41 is equivalent to
42 .BI "putc(" c ", " stdout ) \fR.
43 .P
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 .P
51 .BR puts ()
52 writes the string
53 .I s
54 and a trailing newline
55 to
56 .IR stdout .
57 .P
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 .P
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 .P
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 .TS
88 allbox;
89 lbx lb lb
90 l l l.
91 Interface Attribute Value
92 T{
93 .na
94 .nh
95 .BR fputc (),
96 .BR fputs (),
97 .BR putc (),
98 .BR putchar (),
99 .BR puts ()
100 T} Thread safety MT-Safe
101 .TE
102 .SH STANDARDS
103 C11, POSIX.1-2008.
104 .SH HISTORY
105 POSIX.1-2001, C89, C99.
106 .SH BUGS
107 It is not advisable to mix calls to output functions from the
108 .I stdio
109 library with low-level calls to
110 .BR write (2)
111 for the file descriptor associated with the same output stream; the results
112 will be undefined and very probably not what you want.
113 .SH SEE ALSO
114 .BR write (2),
115 .BR ferror (3),
116 .BR fgets (3),
117 .BR fopen (3),
118 .BR fputwc (3),
119 .BR fputws (3),
120 .BR fseek (3),
121 .BR fwrite (3),
122 .BR putwchar (3),
123 .BR scanf (3),
124 .BR unlocked_stdio (3)