logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

fputs.3p (4664B)


  1. '\" et
  2. .TH FPUTS "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. fputs
  12. \(em put a string on a stream
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdio.h>
  17. .P
  18. int fputs(const char *restrict \fIs\fP, FILE *restrict \fIstream\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fIfputs\fR()
  27. function shall write the null-terminated string pointed to by
  28. .IR s
  29. to the stream pointed to by
  30. .IR stream .
  31. The terminating null byte shall not be written.
  32. .P
  33. The last data modification and last file status change timestamps
  34. of the file shall be marked for update between the successful
  35. execution of
  36. \fIfputs\fR()
  37. and the next successful completion of a call to
  38. \fIfflush\fR()
  39. or
  40. \fIfclose\fR()
  41. on the same stream or a call to
  42. \fIexit\fR()
  43. or
  44. \fIabort\fR().
  45. .SH "RETURN VALUE"
  46. Upon successful completion,
  47. \fIfputs\fR()
  48. shall return a non-negative number. Otherwise, it shall return EOF,
  49. set an error indicator for the stream,
  50. and set
  51. .IR errno
  52. to indicate the error.
  53. .SH ERRORS
  54. Refer to
  55. .IR "\fIfputc\fR\^(\|)".
  56. .LP
  57. .IR "The following sections are informative."
  58. .SH EXAMPLES
  59. .SS "Printing to Standard Output"
  60. .P
  61. The following example gets the current time, converts it to a string
  62. using
  63. \fIlocaltime\fR()
  64. and
  65. \fIasctime\fR(),
  66. and prints it to standard output using
  67. \fIfputs\fR().
  68. It then prints the number of minutes to an event for which it is
  69. waiting.
  70. .sp
  71. .RS 4
  72. .nf
  73. #include <time.h>
  74. #include <stdio.h>
  75. \&...
  76. time_t now;
  77. int minutes_to_event;
  78. \&...
  79. time(&now);
  80. printf("The time is ");
  81. fputs(asctime(localtime(&now)), stdout);
  82. printf("There are still %d minutes to the event.\en",
  83. minutes_to_event);
  84. \&...
  85. .fi
  86. .P
  87. .RE
  88. .SH "APPLICATION USAGE"
  89. The
  90. \fIputs\fR()
  91. function appends a
  92. <newline>
  93. while
  94. \fIfputs\fR()
  95. does not.
  96. .P
  97. This volume of POSIX.1\(hy2017 requires that successful completion simply return a non-negative
  98. integer. There are at least three known different implementation
  99. conventions for this requirement:
  100. .IP " *" 4
  101. Return a constant value.
  102. .IP " *" 4
  103. Return the last character written.
  104. .IP " *" 4
  105. Return the number of bytes written. Note that this implementation
  106. convention cannot be adhered to for strings longer than
  107. {INT_MAX}
  108. bytes as the value would not be representable in the return type of the
  109. function. For backwards-compatibility, implementations can return the
  110. number of bytes for strings of up to
  111. {INT_MAX}
  112. bytes, and return
  113. {INT_MAX}
  114. for all longer strings.
  115. .SH RATIONALE
  116. The
  117. \fIfputs\fR()
  118. function is one whose source code was specified in the referenced \fIThe C Programming Language\fP. In the
  119. original edition, the function had no defined return value, yet many
  120. practical implementations would, as a side-effect, return the value of the
  121. last character written as that was the value remaining in the accumulator
  122. used as a return value. In the second edition of the book, either the
  123. fixed value 0 or EOF would be returned depending upon the return value of
  124. \fIferror\fR();
  125. however, for compatibility with extant implementations, several
  126. implementations would, upon success, return a positive value representing
  127. the last byte written.
  128. .SH "FUTURE DIRECTIONS"
  129. None.
  130. .SH "SEE ALSO"
  131. .IR "Section 2.5" ", " "Standard I/O Streams",
  132. .IR "\fIfopen\fR\^(\|)",
  133. .IR "\fIputc\fR\^(\|)",
  134. .IR "\fIputs\fR\^(\|)"
  135. .P
  136. The Base Definitions volume of POSIX.1\(hy2017,
  137. .IR "\fB<stdio.h>\fP"
  138. .\"
  139. .SH COPYRIGHT
  140. Portions of this text are reprinted and reproduced in electronic form
  141. from IEEE Std 1003.1-2017, Standard for Information Technology
  142. -- Portable Operating System Interface (POSIX), The Open Group Base
  143. Specifications Issue 7, 2018 Edition,
  144. Copyright (C) 2018 by the Institute of
  145. Electrical and Electronics Engineers, Inc and The Open Group.
  146. In the event of any discrepancy between this version and the original IEEE and
  147. The Open Group Standard, the original IEEE and The Open Group Standard
  148. is the referee document. The original Standard can be obtained online at
  149. http://www.opengroup.org/unix/online.html .
  150. .PP
  151. Any typographical or formatting errors that appear
  152. in this page are most likely
  153. to have been introduced during the conversion of the source files to
  154. man page format. To report such errors, see
  155. https://www.kernel.org/doc/man-pages/reporting_bugs.html .