1FPUTS(3P)                  POSIX Programmer's Manual                 FPUTS(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       fputs — put a string on a stream
13

SYNOPSIS

15       #include <stdio.h>
16
17       int fputs(const char *restrict s, FILE *restrict stream);
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  fputs() function shall write the null-terminated string pointed to
26       by s to the stream pointed to by stream.   The  terminating  null  byte
27       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       fputs()  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, fputs() shall return a non-negative number.
36       Otherwise,  it shall return EOF, set an error indicator for the stream,
37       and set errno 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       fputs().  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           fputs(asctime(localtime(&now)), stdout);
61           printf("There are still %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       The fputs() function is one whose source code was specified in the ref‐
85       erenced  The C Programming Language. In the original edition, the func‐
86       tion had no defined return value, yet  many  practical  implementations
87       would, as a side-effect, return the value of the last character written
88       as that was the value remaining in the accumulator  used  as  a  return
89       value.  In  the second edition of the book, either the fixed value 0 or
90       EOF would be returned depending upon the return value of ferror(); how‐
91       ever,  for compatibility with extant implementations, several implemen‐
92       tations would, upon success, return a positive value  representing  the
93       last byte written.
94

FUTURE DIRECTIONS

96       None.
97

SEE ALSO

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