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
11

NAME

13       fputs — put a string on a stream
14

SYNOPSIS

16       #include <stdio.h>
17
18       int fputs(const char *restrict s, FILE *restrict stream);
19

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

46   Printing to Standard Output
47       The following example gets the current time, converts it  to  a  string
48       using localtime() and asctime(), and prints it to standard output using
49       fputs().  It then prints the number of minutes to an event for which it
50       is waiting.
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‐2008 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‐2008, <stdio.h>
102
104       Portions  of  this text are reprinted and reproduced in electronic form
105       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
106       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
107       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
108       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
109       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
110       event of any discrepancy between this version and the original IEEE and
111       The Open Group Standard, the original IEEE and The Open Group  Standard
112       is  the  referee document. The original Standard can be obtained online
113       at http://www.unix.org/online.html .
114
115       Any typographical or formatting errors that appear  in  this  page  are
116       most likely to have been introduced during the conversion of the source
117       files to man page format. To report such errors,  see  https://www.ker
118       nel.org/doc/man-pages/reporting_bugs.html .
119
120
121
122IEEE/The Open Group                  2013                            FPUTS(3P)
Impressum