1PUTS(3P)                   POSIX Programmer's Manual                  PUTS(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       puts — put a string on standard output
13

SYNOPSIS

15       #include <stdio.h>
16
17       int puts(const char *s);
18

DESCRIPTION

20       The functionality described on this reference page is aligned with  the
21       ISO C  standard.  Any  conflict between the requirements described here
22       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
23       defers to the ISO C standard.
24
25       The puts() function shall write the string pointed to by s, followed by
26       a <newline>, to the standard output  stream  stdout.   The  terminating
27       null byte shall not be written.
28
29       The  last  data  modification and last file status change timestamps of
30       the file shall be marked for update between the successful execution of
31       puts()  and  the  next  successful  completion of a call to fflush() or
32       fclose() on the same stream or a call to exit() or abort().
33

RETURN VALUE

35       Upon successful completion, puts() shall return a non-negative  number.
36       Otherwise,  it  shall  return EOF, shall set an error indicator for the
37       stream, and errno shall be set to indicate the error.
38

ERRORS

40       Refer to fputc().
41
42       The following sections are informative.
43

EXAMPLES

45   Printing to Standard Output
46       The following example gets the current time, converts it  to  a  string
47       using localtime() and asctime(), and prints it to standard output using
48       puts().  It then prints the number of minutes to an event for which  it
49       is waiting.
50
51
52           #include <time.h>
53           #include <stdio.h>
54           ...
55           time_t now;
56           int minutes_to_event;
57           ...
58           time(&now);
59           printf("The time is ");
60           puts(asctime(localtime(&now)));
61           printf("There are %d minutes to the event.\n",
62               minutes_to_event);
63           ...
64

APPLICATION USAGE

66       The puts() function appends a <newline>, while fputs() does not.
67
68       This  volume of POSIX.1‐2017 requires that successful completion simply
69       return a non-negative integer. There are at least three known different
70       implementation conventions for this requirement:
71
72        *  Return a constant value.
73
74        *  Return the last character written.
75
76        *  Return  the  number of bytes written. Note that this implementation
77           convention cannot be adhered to for strings longer  than  {INT_MAX}
78           bytes as the value would not be representable in the return type of
79           the function.  For  backwards  compatibility,  implementations  can
80           return  the  number  of bytes for strings of up to {INT_MAX} bytes,
81           and return {INT_MAX} for all longer strings.
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       Section 2.5, Standard I/O Streams, fopen(), fputs(), putc()
91
92       The Base Definitions volume of POSIX.1‐2017, <stdio.h>
93
95       Portions of this text are reprinted and reproduced in  electronic  form
96       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
97       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
98       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
99       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
100       event of any discrepancy between this version and the original IEEE and
101       The Open Group Standard, the original IEEE and The Open Group  Standard
102       is  the  referee document. The original Standard can be obtained online
103       at http://www.opengroup.org/unix/online.html .
104
105       Any typographical or formatting errors that appear  in  this  page  are
106       most likely to have been introduced during the conversion of the source
107       files to man page format. To report such errors,  see  https://www.ker
108       nel.org/doc/man-pages/reporting_bugs.html .
109
110
111
112IEEE/The Open Group                  2017                             PUTS(3P)
Impressum