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